Loading...
Searching...
No Matches
Logger::Logger Class Reference

Implements main logger class whose instance will be used by user code when logging. More...

Inheritance diagram for Logger::Logger:
[legend]

## Public Member Functions

| addAppender (LoggerAppender appender)
| Adds an appender to the appender list. More...
| callAppenders (LoggerEvent event)
| Forwards the given logging event to all linked appenders. More...
| constructor (LoggerLevel level)
| Creates the object with an empty name and the given initial level. More...
| constructor (string name, LoggerLevel level)
| Creates the object. More...
| constructor (string name='')
| Creates the object. More...
*LoggerLevel | decLevel ()
| Decrement logger level. More...
bool | getAdditivity ()
| Returns the additivity flag.
list< LoggerAppender > | getAppenders ()
| Returns the appender list. More...
*LoggerLevel | getLevel (bool effective=True)
| Returns the logging level. More...
string | getName ()
| Returns the logger name.
*Logger | getParent ()
| Returns the parent logger, if any.
*LoggerLevel | incLevel ()
| Increment logger level. More...
| removeAllAppenders ()
| Clears the appender list by removing all appenders.
| removeAppender (LoggerAppender appender)
| Removes the appender from the list. More...
| setAdditivity (bool enable)
| Sets the additivity flag; when additivity is active, events are passed to parent loggers. More...
| setLevel (*LoggerLevel level)
| Sets the logging level. More...
| setLevel (int level)
| Sets the logging level. More...
| setLevel (string level)
| Sets the logging level. More...
| setParent (*Logger value)
| Sets the parent logger. More...

## Protected Member Functions

hash< CallStackInfo > | getLocation ()
| Returns the call location where the log function was called from.

## Private Member Functions

transient RWLock | lock ()
| The lock to protect object manipulation.

## Static Private Member Functions

static RWLock | hierarchyLock ()
| The lock to protect access to parent/child hierarchy.

## Private Attributes

bool | additivity = True
| Logger additivity. If set to true then child loggers will inherit the appenders of their ancestors by default.
list< LoggerAppender > | appenders
| A collection of appenders linked to this logger.
*LoggerLevel | currentLevel
| The assigned Logger level. If NOTHING, the parent level is used.
string | name
| The name of this Logger instance.
*Logger | parent
| The parent logger. Unassigned if this is the root logger.

## Detailed Description

Implements main logger class whose instance will be used by user code when logging.

The Logger object is provided to user code. When a log is triggered then message, arguments, current code position, time are appended into LoggerEvent event instance when the logging level is enabled. The event is passed to all registered appenders in the given Logger as well as in parents in the hierarchy when additivity is enabled.

## Member Function Documentation

## addAppender()

Logger::Logger::addAppender | ( | LoggerAppender | appender | ) |

Adds an appender to the appender list.

Parameters

  appender | add a new LoggerAppender

Exceptions

  LOGGER-ERROR | exception if appender is already in list

## callAppenders()

Logger::Logger::callAppenders | ( | LoggerEvent | event | ) |

Forwards the given logging event to all linked appenders.

Parameters

  event | the event to forward

## constructor() [1/3]

Logger::Logger::constructor | ( | LoggerLevel | level | ) |

Creates the object with an empty name and the given initial level.

Parameters

  level | the initial level for the logger

## constructor() [2/3]

Logger::Logger::constructor | ( | string | name,
|  | LoggerLevel | level
| ) |  |

Creates the object.

Parameters

  name | the name of the object
  level | the initial level for the logger

## constructor() [3/3]

Logger::Logger::constructor | ( | string | name = `''` | ) |

Creates the object.

Parameters

  name | the name of the object

## decLevel()

*LoggerLevel Logger::Logger::decLevel | ( |  | ) |

Decrement logger level.

Returns
  current `LoggerLevel`

## getAppenders()

list< LoggerAppender > Logger::Logger::getAppenders | ( |  | ) |

Returns the appender list.

Note that the appender list may be manipulated in another thread as internal lock is released when list is returned

## getLevel()

*LoggerLevel Logger::Logger::getLevel | ( | bool | effective = `True` | ) |

Returns the logging level.

Parameters

  effective | if False then get current level which can be NOTHING, if True then get level which might be inherited from parent, Default: True

Exceptions

  LOGGER-ERROR | if cannot get effective level from hierarchy

## incLevel()

*LoggerLevel Logger::Logger::incLevel | ( |  | ) |

Increment logger level.

Returns
  current `LoggerLevel`

## removeAppender()

Logger::Logger::removeAppender | ( | LoggerAppender | appender | ) |

Removes the appender from the list.

Parameters

  appender | the appender to remove

## setAdditivity()

Logger::Logger::setAdditivity | ( | bool | enable | ) |

Sets the additivity flag; when additivity is active, events are passed to parent loggers.

Parameters

  enable | the additivity flag; when additivity is active, events are passed to parent loggers

## setLevel() [1/3]

Logger::Logger::setLevel | ( | *LoggerLevel | level | ) |

Sets the logging level.

Parameters

  level | if nothing then inherits level from parent

## setLevel() [2/3]

Logger::Logger::setLevel | ( | int | level | ) |

Sets the logging level.

Parameters

  level | the logging level to set

## setLevel() [3/3]

Logger::Logger::setLevel | ( | string | level | ) |

Sets the logging level.

Parameters

  level | the logging level as a string

## setParent()

Logger::Logger::setParent | ( | *Logger | value | ) |

Sets the parent logger.

Parameters

  value | the parent logger

Exceptions

  LOGGER-ERROR | in case of circular reference