29 #include "geode_globals.hpp" 35 #ifndef GEODE_HIGHEST_LOG_LEVEL 36 #define GEODE_HIGHEST_LOG_LEVEL All 39 #ifndef GEODE_MAX_LOG_FILE_LIMIT 40 #define GEODE_MAX_LOG_FILE_LIMIT (1024 * 1024 * 1024) 43 #ifndef GEODE_MAX_LOG_DISK_LIMIT 44 #define GEODE_MAX_LOG_DISK_LIMIT (1024ll * 1024ll * 1024ll * 1024ll) 47 #define _GF_MSG_LIMIT 8192 65 #define GF_LOG(level, expr) \ 66 if (level > apache::geode::client::Log::logLevel()) { \ 68 apache::geode::client::Log::log(level, expr) 192 static const char* logFileName();
202 (LogLevel level,
const char* logFileName, int32_t logFileLimit = 0,
203 int64_t logDiskSpaceLimit = 0);
216 static const char* levelToChars(Log::LogLevel level);
223 static LogLevel charsToLevel(
const char* chars);
239 static char* formatLogLine(
char* buf, LogLevel level);
247 return (((s_doingDebug && level == Debug) ||
249 s_logLevel >= level);
255 static void log(LogLevel level,
const char* msg) {
256 if (enabled(level)) put(level, msg);
263 if (enabled(level)) putThrow(level, msg, ex);
270 if (enabled(level)) putCatch(level, msg, ex);
286 static void error(
const char* msg) {
287 if (errorEnabled()) put(Error, msg);
295 if (errorEnabled()) putThrow(Error, msg, ex);
303 if (errorEnabled()) putCatch(Error, msg, ex);
320 if (warningEnabled()) put(Warning, msg);
328 if (warningEnabled()) putThrow(Warning, msg, ex);
336 if (warningEnabled()) putCatch(Warning, msg, ex);
352 static void info(
const char* msg) {
353 if (infoEnabled()) put(Info, msg);
361 if (infoEnabled()) putThrow(Info, msg, ex);
369 if (infoEnabled()) putCatch(Info, msg, ex);
386 if (configEnabled()) put(Config, msg);
394 if (configEnabled()) putThrow(Config, msg, ex);
402 if (configEnabled()) putCatch(Config, msg, ex);
418 static void fine(
const char* msg) {
419 if (fineEnabled()) put(Fine, msg);
427 if (fineEnabled()) putThrow(Fine, msg, ex);
435 if (fineEnabled()) putCatch(Fine, msg, ex);
451 static void finer(
const char* msg) {
452 if (finerEnabled()) put(Finer, msg);
460 if (finerEnabled()) putThrow(Finer, msg, ex);
468 if (finerEnabled()) putCatch(Finer, msg, ex);
485 if (finestEnabled()) put(Finest, msg);
493 if (finestEnabled()) putThrow(Finest, msg, ex);
501 if (finestEnabled()) putCatch(Finest, msg, ex);
518 static void debug(
const char* msg) {
519 if (debugEnabled()) put(Debug, msg);
527 if (debugEnabled()) putThrow(Debug, msg, ex);
535 if (debugEnabled()) putCatch(Debug, msg, ex);
540 static void enterFn(LogLevel level,
const char* functionName);
542 static void exitFn(LogLevel level,
const char* functionName);
547 static LogLevel s_logLevel;
552 enum { s_doingDebug = 1 };
554 enum { s_doingDebug = 0 };
559 static void writeBanner();
563 static void put(LogLevel level,
const char* msg);
565 static void putThrow(LogLevel level,
const char* msg,
const Exception& ex);
567 static void putCatch(LogLevel level,
const char* msg,
const Exception& ex);
574 const char* m_functionName;
575 Log::LogLevel m_level;
578 LogFn(
const char* functionName, Log::LogLevel level = Log::Finest)
579 : m_functionName(functionName), m_level(level) {
580 if (
Log::enabled(m_level)) Log::enterFn(m_level, m_functionName);
584 if (
Log::enabled(m_level)) Log::exitFn(m_level, m_functionName);
588 LogFn(
const LogFn& rhs);
589 void operator=(
const LogFn& rhs);
601 static void debug(
const char* fmt, ...);
602 static void error(
const char* fmt, ...);
603 static void warn(
const char* fmt, ...);
604 static void info(
const char* fmt, ...);
605 static void config(
const char* fmt, ...);
606 static void fine(
const char* fmt, ...);
607 static void finer(
const char* fmt, ...);
608 static void finest(
const char* fmt, ...);
617 if (apache::geode::client::Log::Debug <= \ 618 apache::geode::client::Log::logLevel()) \ 619 apache::geode::client::LogVarargs::debug 624 if (apache::geode::client::Log::Error <= \ 625 apache::geode::client::Log::logLevel()) \ 626 apache::geode::client::LogVarargs::error 631 if (apache::geode::client::Log::Warning <= \ 632 apache::geode::client::Log::logLevel()) \ 633 apache::geode::client::LogVarargs::warn 638 if (apache::geode::client::Log::Info <= \ 639 apache::geode::client::Log::logLevel()) \ 640 apache::geode::client::LogVarargs::info 645 if (apache::geode::client::Log::Config <= \ 646 apache::geode::client::Log::logLevel()) \ 647 apache::geode::client::LogVarargs::config 652 if (apache::geode::client::Log::Fine <= \ 653 apache::geode::client::Log::logLevel()) \ 654 apache::geode::client::LogVarargs::fine 659 if (apache::geode::client::Log::Finer <= \ 660 apache::geode::client::Log::logLevel()) \ 661 apache::geode::client::LogVarargs::finer 666 if (apache::geode::client::Log::Finest <= \ 667 apache::geode::client::Log::logLevel()) \ 668 apache::geode::client::LogVarargs::finest 674 #endif // GEODE_LOG_H_ static void fine(const char *msg)
Logs a message.
Definition: Log.hpp:418
static void log(LogLevel level, const char *msg)
Logs a message at given level.
Definition: Log.hpp:255
static void finestThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:492
static bool enabled(LogLevel level)
Returns whether log messages at given level are enabled.
Definition: Log.hpp:246
static void errorCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:302
Each enum represents a predefined RegionAttributes in a Cache.
Definition: Assert.hpp:31
static bool infoEnabled()
Returns whether "info" log messages are enabled.
Definition: Log.hpp:344
static void warning(const char *msg)
Logs a message.
Definition: Log.hpp:319
#define CPPCACHE_EXPORT
Defines a Geode CPPCACHE export.
Definition: geode_base.hpp:58
static void configThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:393
#define GEODE_HIGHEST_LOG_LEVEL
The interface of the Log class.
Definition: Log.hpp:36
static void finestCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:500
static void configCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:401
static bool debugEnabled()
Returns whether "debug" log messages are enabled.
Definition: Log.hpp:509
static void setLogLevel(LogLevel level)
Set the current log level.
Definition: Log.hpp:185
static void infoThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:360
static bool configEnabled()
Returns whether "config" log messages are enabled.
Definition: Log.hpp:377
static bool warningEnabled()
Returns whether "warning" log messages are enabled.
Definition: Log.hpp:311
static void config(const char *msg)
Logs a message.
Definition: Log.hpp:385
static void info(const char *msg)
Logs a message.
Definition: Log.hpp:352
static void finerThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:459
static void error(const char *msg)
Logs a message.
Definition: Log.hpp:286
static void fineCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:434
static void logCatch(LogLevel level, const char *msg, const Exception &ex)
Logs both a message and caught exception.
Definition: Log.hpp:269
static void fineThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:426
static void debug(const char *msg)
Logs a message.
Definition: Log.hpp:518
static void errorThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:294
static void infoCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:368
static void debugCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:534
A description of an exception that occurred during a cache operation.
Definition: Exception.hpp:45
static void debugThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:526
static bool errorEnabled()
Returns whether "error" log messages are enabled.
Definition: Log.hpp:278
static void finer(const char *msg)
Logs a message.
Definition: Log.hpp:451
static void warningThrow(const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:327
static void finest(const char *msg)
Logs a message.
Definition: Log.hpp:484
These functions are added to facilitate logging in printf format.
Definition: Log.hpp:599
static bool finestEnabled()
Returns whether "finest" log messages are enabled.
Definition: Log.hpp:476
static LogLevel logLevel()
Returns the current log level.
Definition: Log.hpp:180
static void logThrow(LogLevel level, const char *msg, const Exception &ex)
Logs both a message and thrown exception.
Definition: Log.hpp:262
static void finerCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:467
static bool finerEnabled()
Returns whether "finer" log messages are enabled.
Definition: Log.hpp:443
static bool fineEnabled()
Returns whether "fine" log messages are enabled.
Definition: Log.hpp:410
Defines methods available to clients that want to write a log message to their Geode system's shared ...
Definition: Log.hpp:146
static void warningCatch(const char *msg, const Exception &ex)
Writes both a message and caught exception.
Definition: Log.hpp:335
This namespace contains all the Geode C++ API classes, enumerations and globals.