ZDK
|
Debug logging facility. More...
#include <ILog.h>
Public Member Functions | |
virtual ZDK::Shared::Result | LogOpen (ZDK::Shared::String fileName, ZDK::Shared::String oldFileName, ZDK::LoggingLevel maxLevel, intptr_t maxSizeBytes)=0 |
Starts logging. More... | |
virtual void | LogMessage (ZDK::LoggingLevel level, ZDK::LoggingFacility facility, ZDK::Shared::String facilityName, ZDK::Shared::String sourceFileName, int sourceLine, ZDK::Shared::String message)=0 |
Log a message. More... | |
virtual ZDK::Shared::Result | LogClose ()=0 |
Stops logging. More... | |
virtual ZDK::Shared::ItemList< ZDK::LoggingFacility > | ActiveFacilities () const =0 |
Gets the list with all enabled logging facilities. More... | |
virtual void | ActiveFacilities (ZDK::Shared::ItemList< ZDK::LoggingFacility > values)=0 |
Configures the list with all enabled logging facilities. More... | |
virtual bool | ShouldLogFacility (ZDK::LoggingFacility value) const =0 |
Checks whether the given logging facility is enabled. More... | |
![]() | |
virtual ZDK::ZDKHandle | Handle () const =0 |
virtual | operator ZDK::ZDKHandle () const =0 |
virtual void | Initialize ()=0 |
virtual void | ReleaseReference ()=0 |
Debug logging facility.
|
pure virtual |
Gets the list with all enabled logging facilities.
Debug log entries will be added only from the listed facilities.
|
pure virtual |
Configures the list with all enabled logging facilities.
Debug log entries will be added only from the listed facilities.
[in] | value | The list with all active logging facilities |
|
pure virtual |
Stops logging.
Closes the current log file, if open. Any further log requests, both internal and external, will do nothing.
|
pure virtual |
Log a message.
Adds a log entry to the log.
The log format allows putting a "subsystem" in one of the log columns. The subsystem names are short uppercase only tags, optionally followed by a colon ':' and a snother short uppercase only tag signifying a sub-sub-system.
Custom subsystems used by the SDK user must follow the same rules to keep the log parsers simple.
Here is a (mostly complete) list of the tags in use:
RESIP:APP is used extensively in the library but will gradually be phased out in favor of WRAPPER WRAPPER is going to be used for the call managers RESIP (with the exception of :APP) is used by the SIP stack and some platform wrapper utilities ZRTP is the ZRTP implementation MSRP is the MSRP implementation
No parameters are optional.
[in] | level | Log level. If it is higher than the current configured maximum log level the message will be ignored. |
[in] | facility | Short subsystem name in the form of TAG or TAG:SUBTAG |
[in] | facilityName | String representation of the subsystem |
[in] | sourceFileName | Source file name |
[in] | sourceLine | Source file line |
[in] | message | The log message itself |
LoggingLevel, LoggingFacility, LogOpen()
|
pure virtual |
Starts logging.
Starts the log facility. It will be used automatically by most library subsystems to log various events. If logging has already started it will be closed and reopened.
Can be called before StartContext() and/or after StopContext(). The log facility has its own life separate from the context.
The log files are always opened in append mode.
The logging facility will maintain up to two files and automatically rotate them. To enable rotation, set a non-zero maximum file size in "maxSizeBytes" and set the secondary log file name in "oldFileName". If "maxSizeBytes" or "oldFileName" are zero, rotation will be disabled.
The rotation consists of the following operations:
Both file names MUST reside on the same logical file system.
All messages are first filtered by level. The "maxLevel" parameter sets the highest acceptable value, or in other words, the minimum severity level that will be logged. Confusingly, for legacy reasons, the lowest number has the highest severity.
The log format is CSV-like with the sequence " | " (space, pipe, space) as delimiter. The column count is fixed. All columns up to the last will not contain the pipe symbol but may contain white space. The last column is special, as it may contain unescaped pipe symbols and new lines, especially when the network stacks dump entire network messages.
Care must be taken when writing automated log parsers.
Here are the columns with example values:
[in] | fileName | Main log file name |
[in] | oldFileName | Secondary log file. Only used if "maxSizeBytes" is greater than 0. |
[in] | maxLevel | Maximum level to log. Messages with higher level values, meaning lower severity are automatically dropped before filtering. |
[in] | maxSizeBytes | Maximum size for a single log file. Affects both the main and the secondary file, resulting in maximum twice as much space used. |
|
pure virtual |
Checks whether the given logging facility is enabled.
[in] | value | The logging facility to be checked |