DCMTK: dcmtk::log4cplus::Logger Class Reference

DCMTK Version 3.7.0 OFFIS DICOM Toolkit

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | List of all members
dcmtk::log4cplus::Logger Class Reference

This is the central class in the log4cplus package. More...

Inheritance diagram for dcmtk::log4cplus::Logger:

## Public Member Functions
void | assertion (bool assertionVal, const log4cplus::tstring &msg) const
| If `assertionVal` parameter is `false`, then logs `msg` with FATAL_LOG_LEVEL log level.
void | closeNestedAppenders () const
| Close all attached appenders implementing the AppenderAttachable interface.
bool | isEnabledFor (LogLevel ll) const
| Check whether this logger is enabled for a given LogLevel passed as parameter.
void | log (LogLevel ll, const log4cplus::tstring &message, const char *file=NULL, int line=-1) const
| This generic form is intended to be used by wrappers.
void | forcedLog (LogLevel ll, const log4cplus::tstring &message, const char *file=NULL, int line=-1) const
| This method creates a new logging event and logs the event without further checks.
void | callAppenders (const spi::InternalLoggingEvent &event) const
| Call the appenders in the hierrachy starting at `this`.
LogLevel | getChainedLogLevel () const
| Starting from this logger, search the logger hierarchy for a "set" LogLevel and return it.
LogLevel | getLogLevel () const
| Returns the assigned LogLevel, if any, for this Logger.
void | setLogLevel (LogLevel ll)
| Set the LogLevel of this Logger.
Hierarchy & | getHierarchy () const
| Return the the `Hierarchy` where this `Logger` instance is attached.
log4cplus::tstring const & | getName () const
| Return the logger name.
bool | getAdditivity () const
| Get the additivity flag for this Logger instance.
void | setAdditivity (bool additive)
| Set the additivity flag for this Logger instance.
Logger | getParent () const
| Used to retrieve the parent of this Logger in the Logger tree.

## Static Public Member Functions
static bool | exists (const log4cplus::tstring &name)
| Returns `true` if the named logger exists (in the default hierarchy).
static Hierarchy & | getDefaultHierarchy ()
| Return the default Hierarchy instance.
static Logger | getInstance (const log4cplus::tstring &name)
| Retrieve a logger with name `name`.
static Logger | getInstance (const log4cplus::tstring &name, spi::LoggerFactory &factory)
| Like getInstance() except that the type of logger instantiated depends on the type returned by the `spi::LoggerFactory#makeNewLoggerInstance` method of the `factory` parameter.
static Logger | getRoot ()
| Return the root of the default logger hierrachy.
static void | shutdown ()
| Calling this method will safely close and remove all appenders in all the loggers including root contained in the default hierarchy.

## Protected Attributes
spi::LoggerImpl * | value
| This is a pointer to the implementation class.

## Private Member Functions
DCMTK_LOG4CPLUS_PRIVATE | Logger (spi::LoggerImpl *ptr)
| This constructor created a new `Logger` instance with a pointer to a Logger implementation.

## Detailed Description

This is the central class in the log4cplus package.

One of the distintive features of log4cplus are hierarchical loggers and their evaluation.

See the user manual for an introduction on this class.

## Constructor & Destructor Documentation

## ◆ Logger()

DCMTK_LOG4CPLUS_PRIVATE dcmtk::log4cplus::Logger::Logger | ( | spi::LoggerImpl * | ptr | ) |
| private

This constructor created a new `Logger` instance with a pointer to a Logger implementation.

You should not create loggers directly.

Parameters

  ptr | A pointer to the Logger implementation. This value cannot be NULL.

## Member Function Documentation

## ◆ assertion()

void dcmtk::log4cplus::Logger::assertion | ( | bool | assertionVal,
|  | const log4cplus::tstring & | msg ) const

If `assertionVal` parameter is `false`, then logs `msg` with FATAL_LOG_LEVEL log level.

Parameters

  assertionVal | Truth value of assertion condition.
  msg | The message to print if `assertion` is false.

## ◆ callAppenders()

void dcmtk::log4cplus::Logger::callAppenders | ( | const spi::InternalLoggingEvent & | event | ) | const

Call the appenders in the hierrachy starting at `this`.

If no appenders could be found, emit a warning.

This method calls all the appenders inherited from the hierarchy circumventing any evaluation of whether to log or not to log the particular log request.

Parameters

  event | the event to log.

## ◆ exists()

bool dcmtk::log4cplus::Logger::exists | ( | const log4cplus::tstring & | name | ) |
| static

Returns `true` if the named logger exists (in the default hierarchy).

Parameters

  name | The name of the logger to search for.

## ◆ getChainedLogLevel()

LogLevel dcmtk::log4cplus::Logger::getChainedLogLevel | ( |  | ) | const

Starting from this logger, search the logger hierarchy for a "set" LogLevel and return it.

Otherwise, return the LogLevel of the root logger.

The Logger class is designed so that this method executes as quickly as possible.

## ◆ getInstance() [1/2]

Logger dcmtk::log4cplus::Logger::getInstance | ( | const log4cplus::tstring & | name | ) |
| static

Retrieve a logger with name `name`.

If the named logger already exists, then the existing instance will be returned. Otherwise, a new instance is created.

By default, loggers do not have a set LogLevel but inherit it from the hierarchy. This is one of the central features of log4cplus.

Parameters

  name | The name of the logger to retrieve.

## ◆ getInstance() [2/2]

Logger dcmtk::log4cplus::Logger::getInstance | ( | const log4cplus::tstring & | name,
|  | spi::LoggerFactory & | factory )
| static

Like getInstance() except that the type of logger instantiated depends on the type returned by the `spi::LoggerFactory#makeNewLoggerInstance` method of the `factory` parameter.

This method is intended to be used by sub-classes.

Parameters

  name | The name of the logger to retrieve.
  factory | A `spi::LoggerFactory` implementation that will actually create a new Instance.

## ◆ getLogLevel()

LogLevel dcmtk::log4cplus::Logger::getLogLevel | ( |  | ) | const

Returns the assigned LogLevel, if any, for this Logger.

Returns
  LogLevel - the assigned LogLevel, can be `NOT_SET_LOG_LEVEL`.

## ◆ getRoot()

Logger dcmtk::log4cplus::Logger::getRoot | ( |  | ) |
| static

Return the root of the default logger hierrachy.

The root logger is always instantiated and available. It's name is "root".

Nevertheless, calling `Logger.getInstance("root")` does not retrieve the root logger but a logger just under root named "root".

## ◆ isEnabledFor()

bool dcmtk::log4cplus::Logger::isEnabledFor | ( | LogLevel | ll | ) | const

Check whether this logger is enabled for a given LogLevel passed as parameter.

Returns
  boolean True if this logger is enabled for `ll`.

## ◆ shutdown()

void dcmtk::log4cplus::Logger::shutdown | ( |  | ) |
| static

Calling this method will safely close and remove all appenders in all the loggers including root contained in the default hierarchy.

Some appenders such as SocketAppender need to be closed before the application exits. Otherwise, pending logging events might be lost.

The `shutdown` method is careful to close nested appenders before closing regular appenders. This is allows configurations where a regular appender is attached to a logger and again to a nested appender.

The documentation for this class was generated from the following file:

- oflog/include/dcmtk/oflog/logger.h

Generated on for DCMTK Version 3.7.0 by Doxygen 1.16.1