zdk.net
|
Debug logging facility. More...
#include <Log.h>
Public Member Functions | |
Log (ZDK::Shared::Log src) | |
ZDK_NET::Result ^ | LogOpen (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::Result ^ | LogClose () |
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 |
Properties | |
List< ZDK_NET::LoggingFacility >^ | ActiveFacilities [get, set] |
Configures the list with all enabled logging facilities. More... | |
Debug logging facility.
ZDK_NET::Result ^ ZDK_NET::Log::LogClose | ( | ) |
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] | 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 |
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:
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. |
bool ZDK_NET::Log::ShouldLogFacility | ( | ZDK_NET::LoggingFacility | value | ) |
Checks whether the given logging facility is enabled.
[in] | value | The logging facility to be checked |
|
getset |
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 |