Skip to content

Logger

class Logger

The Logger class. Configures spdlog logging system

Functions

Name Description
configure Static method allowing to configure the three appenders and the default priority level config : A hash which must follow the Schema described in the expectedParameters method
useCache Enables the cache sink for the specified logger.
useConsole Enables the console (color) sink for the specified logger name : The logger name on which the sink should work (empty string reflects default logger)
useOstream Enables console sink (backward compatibility)
useFile Enables the rotating file sink for the specified logger.
useAuditFile Enables the rolling file appender on the specified category for auditing.
reset Resets all sinks from all loggers and destroy the cache.
trace Logs trace message using specified logger name : of registered logger fmt : - format string followed by optional args
debug Logs debug message using specified logger name : of registered logger fmt : - format string followed by optional args following : by args
info Logs info message using specified logger name : of registered logger fmt : - format string followed by optional args
warn Logs warn message using specified logger name : of registered logger fmt : - format string followed by optional args
error Logs error message using specified logger name : of registered logger fmt : - format string followed by optional args
critical Logs critical message using specified logger name : of registered logger fmt : - format string followed by optional args
setPriority Allows to set the priority (level) filter for specified logger or globally (empty 'logger') priority : TRACE,DEBUG,INFO,WARN,ERROR,CRITICAL logger : The category to apply the filter to (empty string reflects default logger)
getPriority Retrieve the currently enabled priority level for the given logger name or global level logger : The logger name (empty string reflects default logger)
getCachedContent Get (log) messages in internal ringbuffer

Function Details

configure

static void configure(const karabo::data::Hash& config)

Static method allowing to configure the three appenders and the default priority level

config : A hash which must follow the Schema described in the expectedParameters method

critical

template <typename... Args> static void critical(const std::string& name, spdlog::format_string_t<Args...> fmt, Args&&... args)

Logs critical message using specified logger

name : of registered logger

fmt : - format string followed by optional args

debug

template <typename... Args> static void debug(const std::string& name, spdlog::format_string_t<Args...> fmt, Args&&... args)

Logs debug message using specified logger

name : of registered logger

fmt : - format string followed by optional args

following : by args

error

template <typename... Args> static void error(const std::string& name, spdlog::format_string_t<Args...> fmt, Args&&... args)

Logs error message using specified logger

name : of registered logger

fmt : - format string followed by optional args

getCachedContent

static std::vector<karabo::data::Hash> getCachedContent(size_t lim)

Get (log) messages in internal ringbuffer

getPriority

static const std::string getPriority(const std::string& logger = "")

Retrieve the currently enabled priority level for the given logger name or global level

logger : The logger name (empty string reflects default logger)

info

template <typename... Args> static void info(const std::string& name, spdlog::format_string_t<Args...> fmt, Args&&... args)

Logs info message using specified logger

name : of registered logger

fmt : - format string followed by optional args

reset

static void reset()

Resets all sinks from all loggers and destroy the cache. Nothing will be logged after a call to this function.

Use this function to re-configure logger behavior at runtime.

setPriority

static void setPriority(const std::string& priority, const std::string& logger = "")

Allows to set the priority (level) filter for specified logger or globally (empty 'logger')

priority : TRACE,DEBUG,INFO,WARN,ERROR,CRITICAL

logger : The category to apply the filter to (empty string reflects default logger)

trace

template <typename... Args> static void trace(const std::string& name, spdlog::format_string_t<Args...> fmt, Args&&... args)

Logs trace message using specified logger

name : of registered logger

fmt : - format string followed by optional args

useAuditFile

static void useAuditFile(const std::string& name = KARABO_AUDIT_LOGGER)

Enables the rolling file appender on the specified category for auditing.

name : The logger name for audit type messages

useCache

static void useCache(const std::string& name = "", bool inheritSinks = true)

Enables the cache sink for the specified logger.

name : The logger name on which the sink should work (empty string reflects default logger)

useConsole

static void useConsole(const std::string& name = "", bool inheritSinks = true)

Enables the console (color) sink for the specified logger

name : The logger name on which the sink should work (empty string reflects default logger)

useFile

static void useFile(const std::string& name = "", bool inheritSinks = true)

Enables the rotating file sink for the specified logger.

name : The logger name on which the sink should work (empty string reflects default logger)

useOstream

static void useOstream(const std::string name = "", bool inheritSinks = true)

Enables console sink (backward compatibility)

warn

template <typename... Args> static void warn(const std::string& name, spdlog::format_string_t<Args...> fmt, Args&&... args)

Logs warn message using specified logger

name : of registered logger

fmt : - format string followed by optional args