Public Member Functions | Public Attributes | Properties | List of all members
ZDK_NET::Log Class Reference

Debug logging facility. More...

#include <Log.h>

Inheritance diagram for ZDK_NET::Log:

Public Member Functions

 Log (ZDK::Shared::Log src)
ZDK_NET::ResultLogOpen (System::String^ fileName, System::String^ oldFileName, ZDK_NET::LoggingLevel maxLevel, long long maxSizeBytes)
 Starts logging. More...
void LogMessage (ZDK_NET::LoggingLevel level, ZDK_NET::LoggingFacility facility, System::String^ facilityName, System::String^ sourceFileName, int sourceLine, System::String^ message)
 Log a message. More...
ZDK_NET::ResultLogClose ()
 Stops logging. More...
bool ShouldLogFacility (ZDK_NET::LoggingFacility value)
 Checks whether the given logging facility is enabled. More...
virtual long long Handle () override
virtual void Initialize () override
virtual void ReleaseReference () override

Public Attributes

ZDK::ILog * cppRef = nullptr


List< ZDK_NET::LoggingFacility >^ ActiveFacilities [get, set]
 Configures the list with all enabled logging facilities. More...

Detailed Description

Debug logging facility.

Member Function Documentation

◆ LogClose()

ZDK_NET::Result ^ ZDK_NET::Log::LogClose ( )

Stops logging.

Closes the current log file, if open. Any further log requests, both internal and external, will do nothing.

Result of the closing
See also

◆ LogMessage()

void ZDK_NET::Log::LogMessage ( ZDK_NET::LoggingLevel  level,
ZDK_NET::LoggingFacility  facility,
System::String^  facilityName,
System::String^  sourceFileName,
int  sourceLine,
System::String^  message 

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]levelLog level. If it is higher than the current configured maximum log level the message will be ignored.
[in]facilityShort subsystem name in the form of TAG or TAG:SUBTAG
[in]facilityNameString representation of the subsystem
[in]sourceFileNameSource file name
[in]sourceLineSource file line
[in]messageThe log message itself
See also
LoggingLevel, LoggingFacility, LogOpen()

◆ LogOpen()

ZDK_NET::Result ^ ZDK_NET::Log::LogOpen ( System::String^  fileName,
System::String^  oldFileName,
ZDK_NET::LoggingLevel  maxLevel,
long long  maxSizeBytes 

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:

  1. The log file handle is closed.
  2. If the old file exists, it is removed.
  3. The log file is renamed.
  4. The log file handle is reopened.

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:

  1. Log level (textual): DEBUG, NFO, ...
  2. Timestamp: 20160217-163725.551
  3. Subsystem tag: RESIP:APP, MSRP, WRAPPER, ...
  4. Thread id: 12204, 0xfefeb000
  5. Source file and line: audio_builder.cpp:93
  6. Log message: Unregister source= 0x80f3a4d0 ...
[in]fileNameMain log file name
[in]oldFileNameSecondary log file. Only used if "maxSizeBytes" is greater than 0.
[in]maxLevelMaximum level to log. Messages with higher level values, meaning lower severity are automatically dropped before filtering.
[in]maxSizeBytesMaximum size for a single log file. Affects both the main and the secondary file, resulting in maximum twice as much space used.
Result of the opening
See also
LoggingLevel, Result

◆ ShouldLogFacility()

bool ZDK_NET::Log::ShouldLogFacility ( ZDK_NET::LoggingFacility  value)

Checks whether the given logging facility is enabled.

[in]valueThe logging facility to be checked
Whether or not the given facillity should be logged
See also

Property Documentation

◆ ActiveFacilities

List< ZDK_NET:: LoggingFacility>^ ZDK_NET::Log::ActiveFacilities

Configures the list with all enabled logging facilities.

Debug log entries will be added only from the listed facilities.

[in]valueThe list with all active logging facilities
See also

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