You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 18 Next »

The C++ implementation of the logging system is based in ACE Logging and is part of the ACS/LGPL/CommonSoftware/logging module. Additionally there's the ACSLog service in ACS/LGPL/CommonSoftware/acslog module, which offers an entry point for using the logging system by any part of the system. Specifically it is used by Python logging framework for connecting with the central logger.

Design

Class Diagram

Details

BaseLog

The base log is an abstract parent class for several classes in the logging implementation and it also defines some basic information:

  • Priority enum defining log levels
  • FIELD_UNAVAILABLE
  • GLOBAL_LOGGER_NAME
  • ANONYMOUS_LOGGER_NAME
  • STATIC_LOGGER_NAME

As a parent class it defines several interface methods as well as implementing a couple of implementation-agnostic methods to be used by child classes.

It holds a reference to a LoggingStatistics instance, but it does not use it directly, this is to be used by child classes to calculate statistics about the logging calls. A recommendation is to move this reference out of the BaseLog class to the Logger class, because the BaseLog class is also inherited by the Handler class and their instances don't require the LoggingStatistics reference.

LoggingStatistics

The LoggingStatistics class is utility class for calculating and storing statistics about the logs that have been processed by a specific logger. There are some configurable parameters:

  • statisticsCalculationPeriod: Time used for retrieving data before calculating statistics. Default 10 minutes.
  • statisticsGranularity: Time unit used for calculations (i.e. logs per second, logs per minute, etc.). Default 1 second.

It calculates 5 statistics:

  • messageStatistics: Number of log messages per granularity unit.
  • errorStatistics: Number of log errors per granularity unit.
  • messageIncrement: Number of log messages since last calculation.
  • errorIncrement: Number of log errors since last calculation.
  • actualStatisticsPeriod: Actual period of time which was used to gather data before calculating statistics.
    • Usually close to statisticsCalculationPeriod
    • May be different when there's a change of configuration or during the destruction of the logger

Logger

This is the main class in the logging system, which is eventually exposes its interface to other components:

  • addHandler: Adding multiple handlers for the log messages
  • removeHandler: Remove a registered handler
  • setLevels: Setting the log level priority for remote and local handling
  • log: Delegates the logging task to each of its logging handlers
    • Handles interaction with loggingStatistics instance (stats) as well
  • Other getter and setter methods

Additionally, it handles three singleton loggers (global, anonymous, static). The anonymous and static loggers are initialized the first time they're used as child of the global logger. The global logger is created the first time it's used.

Logger_ptr

Logger_ptr is a sub-class from Logger class, which is used as a singleton to store references to global, anonymous, static and a set of named loggers. This is only used from the Logger class.

LogTrace

A convenience class that logs when its constructor and destructor are called, including the time taken between the two calls.

StopWatch

A convenience class that logs when its constructor and destructor are called. It monitors the time taken between the two calls and reports if the configured limit time is exceeded.

Loggable

A small utility class that enables class logging by providing a simple getLogger() method. The logger to be used is either the global logger or a named logger obtained when the constructor is executed.

GenericLogger

A logger that is initialized with an StdoutHandler. It offers the getLogger method returning named loggers as GenericLogger instances.

ACSLogger

A logger that is initialized with the LogSvcHandler. It offers the getLogger method returning named loggers as ACSLogger instances.

Additionally it offers mutex acquire/release methods for convenience.

Handler

The Handler base class defines a set of common methods that all handlers should have:

  • setLevels: Set the remote and local levels for handlers if they're matched with the given type (Implementation specific). By default handlers set the general level (to the given remote level) and ignore the local and type parameters as well as avoid interacting with the remoteLevel and localLevel methods and variables.
  • (get|set)Level: Interact with the general log level for the handler.
  • (get|set)RemoteLevel/(get|set)LocalLevel: Interact with the remote or local level for the handler.
  • (get|set)RemoteLevelType/(get|set)LocalLevelType: Interact with the remote or local level type for the handler.

StdoutHandler

Extends the handler functionality by adding a method to get the name of the handler (Hard-coded to "Stdout").

Provides a basic log method implementation to print to the stdout with printf. It adds the support for setting the log level through the ACS_LOG_STDOUT variable.

LogSvcHandler

Extends the handler functionality by adding a method to get the name of the handler (Hard-coded to "acsLogSvc").

The LogSvcHandler is the first part of the logging system to relate with ACE Logger. It offers two convenience functions:

  • ace2acsPriority/acs2acePriority: To convert between ACE and ACS log levels (priority)

Overrides the setLevels implementation by considering local/remote levels and the log level type. It defines the following log level types:

  • DYNAMIC_LOG_LEVEL (1)
  • CDB_REFRESH_LOG_LEVEL (2)
  • ENV_LOG_LEVEL (3)
  • CDB_LOG_LEVEL (4)
  • DEFAULT_LOG_LEVEL (5)
  • NOT_DEFINED_LOG_LEVEL (6)

Using these log level types, it sets the log levels if the handler log level type is greater or equal than the given type.

It adds the support for setting the local log level through the ACS_LOG_STDOUT variable and to the remote log level through ACS_LOG_CENTRAL variable.

It makes an implementation of the log method based on the LoggingProxy and the ACE_Log_Msg classes to interact with the local (stdout) and remote (logging service) endpoints.

ACE_Log_Msg

The ACE_Log_Msg is part of the ACE Logging implementation in ACE middle-ware. It's purpose is to delegate a log call to a callback instance of the ACE_Log_Msg_Callback class. The LoggingProxy is an extension of this class.

The main purpose of the ACE_Log_Msg class is to allow formatted error messages to be printed in a thread-safe manner to various locations, such as stderr, cerr, a distributed logger, etc. while at the same time setting a priority (log level) to be considered for the logging to take place.

LoggingProxy

The LoggingProxy class is an extension of the ACE_Log_Msg_Callback class, and is one of the central parts of C++ ACS Logging System.

LogLevelDefinition

A class to encapsulate the different log levels accepted by ACS while offering convenient method to create an instance by value or by name, and also a conversion from ACE priorities to ACS log level.

LogThrottle

LogThrottleAlarm

CentralLogger

ACE_Log_Msg_Backend

CacheLogger

LocalFileLogger

LocalSyslogLogger

RemoteSyslogLogger

Module: logging

The module has two libraries and to executables:

  • libbaselogging.so
  • liblogging.so
  • loggingService
  • loggingClient

Library: baselogging

Library: logging

Executable: loggingService

Executable: loggingClient

Module: acslog

The module has only one executable

  • acsLogSvc

Executable: acsLogSvc

  • No labels