|
Senzing C++ SDK
C++ SDK for Senzing v4, patterned after the official C# SDK
|
Senzing native logging (libSzLogging). More...
#include <SzLogging.hpp>

Public Member Functions | |
| virtual | ~SzLogging ()=default |
| virtual std::unique_ptr< SzLogRegistration > | RegisterCallback (const SzLogCallbackOptions &options, SzLogCallback callback)=0 |
| Registers callback for messages from every thread (SzLogging_registerCallbackWithFormat). | |
| virtual std::unique_ptr< SzLogRegistration > | RegisterThreadLocalCallback (const SzLogCallbackOptions &options, SzLogCallback callback)=0 |
| Registers callback for messages logged on the CALLING OS THREAD only. | |
| virtual void | SetDefaultCallback (const SzLogCallbackOptions &options, SzLogCallback callback)=0 |
| Makes callback the default output, at options.MinLevel() and in options.Format() (SzLogging_setDefaultCallback, then SzLogging_setDefaultFormatter for a format other than Legacy). | |
| virtual void | SetDefaultOutput (const SzLogOutput &output)=0 |
| Sets the default output (SzLogging_setDefaultOutput). | |
| virtual SzLogOutput | GetDefaultOutput ()=0 |
| The current default output (SzLogging_getDefaultOutput). | |
| virtual void | SetDefaultFormat (SzLogFormat format)=0 |
| Sets the default output's format (SzLogging_setDefaultFormatter). | |
| virtual SzLogFormat | GetDefaultFormat ()=0 |
| The default output's format (SzLogging_getDefaultFormatter). | |
| virtual void | SetDefaultLogLevel (SzLogLevel level)=0 |
| Sets the default output's level (SzLogging_setLogLevel). | |
| virtual SzLogLevel | GetDefaultLogLevel ()=0 |
| The default output's level, exactly what SetDefaultLogLevel set (SzLogging_getDefaultLogLevel). | |
| virtual SzLogLevel | GetEffectiveLogLevel ()=0 |
| The effective level (SzLogging_getLogLevel): the minimum over the default output and every registered callback. | |
| SzLogCapture | CaptureThreadLogs (const SzLogCallbackOptions &options) |
| Captures the records logged on the calling thread until SzLogCapture::Finish(): one thread-local registration (RegisterThreadLocalCallback) whose callback owns the buffer. | |
Senzing native logging (libSzLogging).
Obtain it with SzEnvironment::GetLogging().
All state lives in native: each method is one native call, and each registration is its own native registration. Binds the Senzing 4.5.0 API; methods that need Senzing >= 4.5.1 / 4.6.0 throw SzConfigurationException.
Senzing 4.5.0 usage rule: change registrations, the default callback, the default output or the default format only while no engine threads are running (before the first engine initialization or after Destroy()). SetDefaultLogLevel and GetEffectiveLogLevel are safe at any time.
|
virtualdefault |
|
inlinenodiscard |
Captures the records logged on the calling thread until SzLogCapture::Finish(): one thread-local registration (RegisterThreadLocalCallback) whose callback owns the buffer.
Requires Senzing >= 4.5.1 / 4.6.0 (thread-local delivery, GDEV-4960); throws SzConfigurationException on 4.5.0.
|
nodiscardpure virtual |
The default output's format (SzLogging_getDefaultFormatter).
Throws SzConfigurationException: requires Senzing >= 4.5.1 / 4.6.0.
Implemented in senzing::sdk::core::SzCoreLogging.
|
nodiscardpure virtual |
The default output's level, exactly what SetDefaultLogLevel set (SzLogging_getDefaultLogLevel).
Throws SzConfigurationException: requires Senzing >= 4.5.1 / 4.6.0.
Implemented in senzing::sdk::core::SzCoreLogging.
|
nodiscardpure virtual |
The current default output (SzLogging_getDefaultOutput).
Throws SzConfigurationException: requires Senzing >= 4.5.1 / 4.6.0.
Implemented in senzing::sdk::core::SzCoreLogging.
|
nodiscardpure virtual |
The effective level (SzLogging_getLogLevel): the minimum over the default output and every registered callback.
A message below it is not even formatted. Safe at any time.
Throws, for a negative native return (from Senzing >= 4.5.1 / 4.6.0 headers), SzBadInputException (-1, -2), SzUnrecoverableException (-3: process exit in progress) or SzException (any other value, also a non-negative value outside SzLogLevel).
Implemented in senzing::sdk::core::SzCoreLogging.
|
nodiscardpure virtual |
Registers callback for messages from every thread (SzLogging_registerCallbackWithFormat).
The returned registration unregisters when destroyed. While it lives, native lowers the effective level to options.MinLevel() if needed.
Throws SzBadInputException for an empty callback or an out-of-range level/format; SzConfigurationException when called from inside a log callback (needs Senzing >= 4.5.1 / 4.6.0); SzUnrecoverableException when native refuses the registration (process exit in progress).
Implemented in senzing::sdk::core::SzCoreLogging.
|
nodiscardpure virtual |
Registers callback for messages logged on the CALLING OS THREAD only.
Requires Senzing >= 4.5.1 / 4.6.0: Senzing 4.5.0 accepts a thread-local registration but never delivers to it (GDEV-4960), so on 4.5.0 this throws SzConfigurationException rather than registering a callback that never fires. Until then, register a process-wide callback and group records by SzLogRecord::ThreadHash().
Implemented in senzing::sdk::core::SzCoreLogging.
|
pure virtual |
Makes callback the default output, at options.MinLevel() and in options.Format() (SzLogging_setDefaultCallback, then SzLogging_setDefaultFormatter for a format other than Legacy).
There is no handle: the callback stays until SetDefaultOutput or another SetDefaultCallback replaces it. On Senzing 4.5.0 the replaced callback is LEAKED (there is no release hook), so set a default callback once.
Throws SzBadInputException for an empty callback or an out-of-range level/format; SzConfigurationException when called from inside a log callback.
Implemented in senzing::sdk::core::SzCoreLogging.
|
pure virtual |
Sets the default output's format (SzLogging_setDefaultFormatter).
Registered callbacks keep their own format. Marks native logging as user-configured (VerboseLogging no longer changes it).
Throws SzBadInputException for an out-of-range format; SzConfigurationException when called from inside a log callback.
Implemented in senzing::sdk::core::SzCoreLogging.
|
pure virtual |
Sets the default output's level (SzLogging_setLogLevel).
Registered callbacks keep their own levels. Safe at any time, from any thread, including inside a callback. Marks native logging as user-configured.
Throws SzBadInputException for an out-of-range level.
Implemented in senzing::sdk::core::SzCoreLogging.
|
pure virtual |
Sets the default output (SzLogging_setDefaultOutput).
The default level is kept. On Senzing 4.5.0 the default format resets to Legacy, so call SetDefaultFormat AFTER this.
For a file, the SDK first opens the path for append (creating it and any missing parent directories, as native does) and throws SzBadInputException naming the path if that fails: Senzing 4.5.0 reports no status, so this is the only way to report an unusable path. The previous output is then kept.
When registered callbacks are your only sink, set SzLogOutput::Null() so messages are not also written to stderr.
Throws SzBadInputException for SzLogOutput::Callback() (get-only), an empty path, a path containing a NUL, or a file that cannot be opened; SzConfigurationException for append mode or when called from inside a log callback (both need Senzing >= 4.5.1 / 4.6.0).
Implemented in senzing::sdk::core::SzCoreLogging.