VMware GemFire Native C++ Reference  9.1
apache::geode::client::Log Class Reference

Defines methods available to clients that want to write a log message to their Geode system's shared log file. More...

Static Public Member Functions

static LogLevel charsToLevel (const char *chars)
 returns log level specified by "chars", or throws IllegalArgumentException. More...
 
static void close ()
 closes logging facility (until next init). More...
 
static void config (const char *msg)
 Logs a message. More...
 
static void configCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool configEnabled ()
 Returns whether "config" log messages are enabled. More...
 
static void configThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static void debug (const char *msg)
 Logs a message. More...
 
static void debugCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool debugEnabled ()
 Returns whether "debug" log messages are enabled. More...
 
static void debugThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static bool enabled (LogLevel level)
 Returns whether log messages at given level are enabled. More...
 
static void error (const char *msg)
 Logs a message. More...
 
static void errorCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool errorEnabled ()
 Returns whether "error" log messages are enabled. More...
 
static void errorThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static void fine (const char *msg)
 Logs a message. More...
 
static void fineCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool fineEnabled ()
 Returns whether "fine" log messages are enabled. More...
 
static void finer (const char *msg)
 Logs a message. More...
 
static void finerCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool finerEnabled ()
 Returns whether "finer" log messages are enabled. More...
 
static void finerThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static void finest (const char *msg)
 Logs a message. More...
 
static void finestCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool finestEnabled ()
 Returns whether "finest" log messages are enabled. More...
 
static void finestThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static void fineThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static char * formatLogLine (char *buf, LogLevel level)
 Fills the provided buffer with formatted log-line given the level and returns the buffer. More...
 
static void info (const char *msg)
 Logs a message. More...
 
static void infoCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool infoEnabled ()
 Returns whether "info" log messages are enabled. More...
 
static void infoThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static void init (LogLevel level, const char *logFileName, int32_t logFileLimit=0, int64_t logDiskSpaceLimit=0)
 Initializes logging facility with given level and filenames. More...
 
static const char * levelToChars (Log::LogLevel level)
 returns character string for given log level. More...
 
static void log (LogLevel level, const char *msg)
 Logs a message at given level. More...
 
static void logCatch (LogLevel level, const char *msg, const Exception &ex)
 Logs both a message and caught exception. More...
 
static const char * logFileName ()
 
static LogLevel logLevel ()
 Returns the current log level. More...
 
static void logThrow (LogLevel level, const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 
static void setLogLevel (LogLevel level)
 Set the current log level. More...
 
static void warning (const char *msg)
 Logs a message. More...
 
static void warningCatch (const char *msg, const Exception &ex)
 Writes both a message and caught exception. More...
 
static bool warningEnabled ()
 Returns whether "warning" log messages are enabled. More...
 
static void warningThrow (const char *msg, const Exception &ex)
 Logs both a message and thrown exception. More...
 

Detailed Description

Defines methods available to clients that want to write a log message to their Geode system's shared log file.

This class must be initialized prior to its use: Log::init

For any logged message the log file will contain:

  • The message's level.
  • The time the message was logged.
  • The id of the connection and thread that logged the message.
  • The message itself which can be a const char* (perhaps with an exception including the exception's stack trace.

A message always has a level. Logging levels are ordered. Enabling logging at a given level also enables logging at higher levels. The higher the level the more important and urgent the message.

The levels, in descending order of severity, are:

  • error (highest severity) is a message level indicating a serious failure. In general error messages should describe events that are of considerable importance and which will prevent normal program execution. They should be reasonably intelligible to end users and to system administrators.

  • warning is a message level indicating a potential problem. In general warning messages should describe events that will be of interest to end users or system managers, or which indicate potential problems.

  • info is a message level for informational messages. Typically info messages should be reasonably significant and should make sense to end users and system administrators.

  • config is a message level for static configuration messages. config messages are intended to provide a variety of static configuration information, to assist in debugging problems that may be associated with particular configurations.

  • fine is a message level providing tracing information. In general the fine level should be used for information that will be broadly interesting to developers. This level is for the lowest volume, and most important, tracing messages.

  • finer indicates a moderately detailed tracing message. This is an intermediate level between fine and finest.

  • finest indicates a very detailed tracing message. Logging calls for entering, returning, or throwing an exception are traced at the finest level.

  • debug (lowest severity) indicates a highly detailed tracing message. In general the debug level should be used for the most voluminous detailed tracing messages.

For each level methods exist that will request a message, at that level, to be logged. These methods are all named after their level.

For each level a method exists that indicates if messages at that level will currently be logged. The names of these methods are of the form: levelEnabled.

Member Function Documentation

static LogLevel apache::geode::client::Log::charsToLevel ( const char *  chars)
static

returns log level specified by "chars", or throws IllegalArgumentException.

Allowed values are identical to the enum declaration above for LogLevel, but with character case ignored.

static void apache::geode::client::Log::close ( )
static

closes logging facility (until next init).

static void apache::geode::client::Log::config ( const char *  msg)
inlinestatic

Logs a message.

The message level is "config".

static void apache::geode::client::Log::configCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "config".

static bool apache::geode::client::Log::configEnabled ( )
inlinestatic

Returns whether "config" log messages are enabled.

static void apache::geode::client::Log::configThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "config".

static void apache::geode::client::Log::debug ( const char *  msg)
inlinestatic

Logs a message.

The message level is "debug".

static void apache::geode::client::Log::debugCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "debug".

static bool apache::geode::client::Log::debugEnabled ( )
inlinestatic

Returns whether "debug" log messages are enabled.

static void apache::geode::client::Log::debugThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "debug".

static bool apache::geode::client::Log::enabled ( LogLevel  level)
inlinestatic

Returns whether log messages at given level are enabled.

static void apache::geode::client::Log::error ( const char *  msg)
inlinestatic

Logs a message.

The message level is "error".

static void apache::geode::client::Log::errorCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "error".

static bool apache::geode::client::Log::errorEnabled ( )
inlinestatic

Returns whether "error" log messages are enabled.

static void apache::geode::client::Log::errorThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "error".

static void apache::geode::client::Log::fine ( const char *  msg)
inlinestatic

Logs a message.

The message level is "fine".

static void apache::geode::client::Log::fineCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "fine".

static bool apache::geode::client::Log::fineEnabled ( )
inlinestatic

Returns whether "fine" log messages are enabled.

static void apache::geode::client::Log::finer ( const char *  msg)
inlinestatic

Logs a message.

The message level is "finer".

static void apache::geode::client::Log::finerCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "finer".

static bool apache::geode::client::Log::finerEnabled ( )
inlinestatic

Returns whether "finer" log messages are enabled.

static void apache::geode::client::Log::finerThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "finer".

static void apache::geode::client::Log::finest ( const char *  msg)
inlinestatic

Logs a message.

The message level is "finest".

static void apache::geode::client::Log::finestCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "finest".

static bool apache::geode::client::Log::finestEnabled ( )
inlinestatic

Returns whether "finest" log messages are enabled.

static void apache::geode::client::Log::finestThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "finest".

static void apache::geode::client::Log::fineThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "fine".

static char* apache::geode::client::Log::formatLogLine ( char *  buf,
LogLevel  level 
)
static

Fills the provided buffer with formatted log-line given the level and returns the buffer.

This assumes that the buffer has large enough space left to hold the formatted log-line (around 70 chars).

This is provided so that applications wishing to use the same format as Geode log-lines can do so easily. A log-line starts with the prefix given below which is filled in by this method: [<level> <date> <time> <timezone> <host>:<process id>=""> <thread id>="">]

This method is not thread-safe for the first invocation. When invoking from outside either <init> should have been invoked, or at least the first invocation should be single-threaded.

static void apache::geode::client::Log::info ( const char *  msg)
inlinestatic

Logs a message.

The message level is "info".

static void apache::geode::client::Log::infoCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "info".

static bool apache::geode::client::Log::infoEnabled ( )
inlinestatic

Returns whether "info" log messages are enabled.

static void apache::geode::client::Log::infoThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "info".

static void apache::geode::client::Log::init ( LogLevel  level,
const char *  logFileName,
int32_t  logFileLimit = 0,
int64_t  logDiskSpaceLimit = 0 
)
static

Initializes logging facility with given level and filenames.

This method is called automatically within DistributedSystem::connect with the log-file, log-level, and log-file-size system properties used as arguments

static const char* apache::geode::client::Log::levelToChars ( Log::LogLevel  level)
static

returns character string for given log level.

The string will be identical to the enum declaration above, except it will be all lower case. Out of range values will throw IllegalArgumentException.

static void apache::geode::client::Log::log ( LogLevel  level,
const char *  msg 
)
inlinestatic

Logs a message at given level.

static void apache::geode::client::Log::logCatch ( LogLevel  level,
const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and caught exception.

static const char* apache::geode::client::Log::logFileName ( )
static
Returns
the name of the current log file. NOTE: This function is for debugging only, as it is not completely thread-safe!
static LogLevel apache::geode::client::Log::logLevel ( )
inlinestatic

Returns the current log level.

static void apache::geode::client::Log::logThrow ( LogLevel  level,
const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

static void apache::geode::client::Log::setLogLevel ( LogLevel  level)
inlinestatic

Set the current log level.

static void apache::geode::client::Log::warning ( const char *  msg)
inlinestatic

Logs a message.

The message level is "warning".

static void apache::geode::client::Log::warningCatch ( const char *  msg,
const Exception ex 
)
inlinestatic

Writes both a message and caught exception.

The message level is "warning".

static bool apache::geode::client::Log::warningEnabled ( )
inlinestatic

Returns whether "warning" log messages are enabled.

static void apache::geode::client::Log::warningThrow ( const char *  msg,
const Exception ex 
)
inlinestatic

Logs both a message and thrown exception.

The message level is "warning".


Pivotal GemFire C++ Cache API Documentation