Senzing C++ SDK
C++ SDK for Senzing v4, patterned after the official C# SDK
Loading...
Searching...
No Matches
senzing::sdk::core::SzCoreLogging Class Referencefinal

Core implementation of SzLogging backed by the native SzLogging_* functions. More...

#include <SzCoreLogging.hpp>

Inheritance diagram for senzing::sdk::core::SzCoreLogging:
Collaboration diagram for senzing::sdk::core::SzCoreLogging:

Public Member Functions

 SzCoreLogging (const SzCoreLogging &)=delete
SzCoreLogging & operator= (const SzCoreLogging &)=delete
std::unique_ptr< SzLogRegistration > RegisterCallback (const SzLogCallbackOptions &options, SzLogCallback callback) override
 Registers callback for messages from every thread (SzLogging_registerCallbackWithFormat).
std::unique_ptr< SzLogRegistration > RegisterThreadLocalCallback (const SzLogCallbackOptions &options, SzLogCallback callback) override
 Registers callback for messages logged on the CALLING OS THREAD only.
void SetDefaultCallback (const SzLogCallbackOptions &options, SzLogCallback callback) override
 Makes callback the default output, at options.MinLevel() and in options.Format() (SzLogging_setDefaultCallback, then SzLogging_setDefaultFormatter for a format other than Legacy).
void SetDefaultOutput (const SzLogOutput &output) override
 Sets the default output (SzLogging_setDefaultOutput).
SzLogOutput GetDefaultOutput () override
 The current default output (SzLogging_getDefaultOutput).
void SetDefaultFormat (SzLogFormat format) override
 Sets the default output's format (SzLogging_setDefaultFormatter).
SzLogFormat GetDefaultFormat () override
 The default output's format (SzLogging_getDefaultFormatter).
void SetDefaultLogLevel (SzLogLevel level) override
 Sets the default output's level (SzLogging_setLogLevel).
SzLogLevel GetDefaultLogLevel () override
 The default output's level, exactly what SetDefaultLogLevel set (SzLogging_getDefaultLogLevel).
SzLogLevel GetEffectiveLogLevel () override
 The effective level (SzLogging_getLogLevel): the minimum over the default output and every registered callback.
Public Member Functions inherited from senzing::sdk::SzLogging
virtual ~SzLogging ()=default
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.

Static Public Member Functions

static SzCoreLogging & GetInstance ()
 The process-wide instance (logging is process-global native state).

Detailed Description

Core implementation of SzLogging backed by the native SzLogging_* functions.

Each method is at most one native call per native concept; there is no SDK registry, dispatch, cache or formatting.

Constructor & Destructor Documentation

◆ SzCoreLogging()

senzing::sdk::core::SzCoreLogging::SzCoreLogging ( const SzCoreLogging & )
delete

Member Function Documentation

◆ GetDefaultFormat()

SzLogFormat senzing::sdk::core::SzCoreLogging::GetDefaultFormat ( )
nodiscardoverridevirtual

The default output's format (SzLogging_getDefaultFormatter).

Throws SzConfigurationException: requires Senzing >= 4.5.1 / 4.6.0.

Implements senzing::sdk::SzLogging.

◆ GetDefaultLogLevel()

SzLogLevel senzing::sdk::core::SzCoreLogging::GetDefaultLogLevel ( )
nodiscardoverridevirtual

The default output's level, exactly what SetDefaultLogLevel set (SzLogging_getDefaultLogLevel).

Throws SzConfigurationException: requires Senzing >= 4.5.1 / 4.6.0.

Implements senzing::sdk::SzLogging.

◆ GetDefaultOutput()

SzLogOutput senzing::sdk::core::SzCoreLogging::GetDefaultOutput ( )
nodiscardoverridevirtual

The current default output (SzLogging_getDefaultOutput).

Throws SzConfigurationException: requires Senzing >= 4.5.1 / 4.6.0.

Implements senzing::sdk::SzLogging.

◆ GetEffectiveLogLevel()

SzLogLevel senzing::sdk::core::SzCoreLogging::GetEffectiveLogLevel ( )
nodiscardoverridevirtual

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).

Implements senzing::sdk::SzLogging.

◆ GetInstance()

SzCoreLogging & senzing::sdk::core::SzCoreLogging::GetInstance ( )
static

The process-wide instance (logging is process-global native state).

◆ operator=()

SzCoreLogging & senzing::sdk::core::SzCoreLogging::operator= ( const SzCoreLogging & )
delete

◆ RegisterCallback()

std::unique_ptr< SzLogRegistration > senzing::sdk::core::SzCoreLogging::RegisterCallback ( const SzLogCallbackOptions & options,
SzLogCallback callback )
nodiscardoverridevirtual

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).

Implements senzing::sdk::SzLogging.

◆ RegisterThreadLocalCallback()

std::unique_ptr< SzLogRegistration > senzing::sdk::core::SzCoreLogging::RegisterThreadLocalCallback ( const SzLogCallbackOptions & options,
SzLogCallback callback )
nodiscardoverridevirtual

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().

Implements senzing::sdk::SzLogging.

◆ SetDefaultCallback()

void senzing::sdk::core::SzCoreLogging::SetDefaultCallback ( const SzLogCallbackOptions & options,
SzLogCallback callback )
overridevirtual

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.

Implements senzing::sdk::SzLogging.

◆ SetDefaultFormat()

void senzing::sdk::core::SzCoreLogging::SetDefaultFormat ( SzLogFormat format)
overridevirtual

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.

Implements senzing::sdk::SzLogging.

◆ SetDefaultLogLevel()

void senzing::sdk::core::SzCoreLogging::SetDefaultLogLevel ( SzLogLevel level)
overridevirtual

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.

Implements senzing::sdk::SzLogging.

◆ SetDefaultOutput()

void senzing::sdk::core::SzCoreLogging::SetDefaultOutput ( const SzLogOutput & output)
overridevirtual

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).

Implements senzing::sdk::SzLogging.


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