caosdb/logging.h

Defines

CAOSDB_LOG_FATAL(Channel)
CAOSDB_LOG_ERROR(Channel)
CAOSDB_LOG_WARN(Channel)
CAOSDB_LOG_INFO(Channel)
CAOSDB_LOG_DEBUG(Channel)
CAOSDB_LOG_TRACE(Channel)
CAOSDB_LOG_ERROR_AND_RETURN_STATUS(Channel, StatusCode, Message)
namespace caosdb::logging

Typedefs

typedef boost::log::sources::severity_channel_logger_mt<int, std::string> boost_logger_class

Functions

auto initialize_logging_defaults() -> int
auto initialize_logging(const LoggingConfiguration &configuration) -> void
void caosdb_log_fatal(const char *channel, const char *msg)

Convenience function for the C interface.

void caosdb_log_error(const char *channel, const char *msg)

Convenience function for the C interface.

void caosdb_log_warn(const char *channel, const char *msg)

Convenience function for the C interface.

void caosdb_log_info(const char *channel, const char *msg)

Convenience function for the C interface.

void caosdb_log_debug(const char *channel, const char *msg)

Convenience function for the C interface.

void caosdb_log_trace(const char *channel, const char *msg)

Convenience function for the C interface.

Variables

const std::string logger_name = "caosdb::logging"
class ConsoleSinkConfiguration : public caosdb::logging::SinkConfiguration

Public Functions

virtual ~ConsoleSinkConfiguration() = default
ConsoleSinkConfiguration(const std::string &name, int level)
virtual auto GetDestination() const -> const std::string& override

Protected Types

typedef SinkConfiguration sink_configuration

Protected Functions

virtual auto Configure(boost::log::settings &settings) const -> void override

Private Members

const std::string destination = "Console"

Friends

friend friend auto initialize_logging_defaults () -> int
friend friend auto initialize_logging (const LoggingConfiguration &logging_configuration) -> void
class FileSinkConfiguration : public caosdb::logging::SinkConfiguration
#include <logging.h>

The file name is the destination, the directory can be set separately.

If there is a directory key in the configuration, that will be used as a default, otherwise it is the current directory.

Public Functions

virtual ~FileSinkConfiguration() = default
FileSinkConfiguration(const std::string &name, int level)
virtual auto GetDestination() const -> const std::string& override
auto SetDirectory(const std::string &directory) -> void

Protected Types

typedef SinkConfiguration sink_configuration

Protected Functions

virtual auto Configure(boost::log::settings &settings) const -> void override

Private Members

const std::string destination = "TextFile"
std::string directory = "./"

Friends

friend friend auto initialize_logging_defaults () -> int
friend friend auto initialize_logging (const LoggingConfiguration &logging_configuration) -> void
class LevelConfiguration
#include <logging.h>

This class stores the integer log level.

Subclassed by caosdb::logging::LoggingConfiguration, caosdb::logging::SinkConfiguration

Public Functions

inline LevelConfiguration(int level)
inline auto GetLevel() const -> int

Private Members

int level
class LoggingConfiguration : public caosdb::logging::LevelConfiguration
#include <logging.h>

This class stores the logging level and log sinks.

Sinks are represented by SinkConfiguration objects.

Public Functions

virtual ~LoggingConfiguration() = default
LoggingConfiguration(int level)
auto AddSink(const std::shared_ptr<SinkConfiguration> &sink) -> void
auto GetSinks() const -> const std::vector<std::shared_ptr<SinkConfiguration>>&

Private Members

std::vector<std::shared_ptr<SinkConfiguration>> sinks
class SinkConfiguration : public caosdb::logging::LevelConfiguration
#include <logging.h>

A logging sink is characterized by a name and destination.

Typical inheriting configurations exist for console, files and syslog.

When a SinkConfiguration is created from a configuration, the sink configuration must contain a destination key which matches one of the keywords for implemented sinks. At the moment of writing this documentation, valid destinations are:

  • file

  • console

  • syslog

A level keyword sets the logging level, if it exists at the sink or logging level of the configuration.

Subclassed by caosdb::logging::ConsoleSinkConfiguration, caosdb::logging::FileSinkConfiguration, caosdb::logging::SyslogSinkConfiguration

Public Functions

virtual ~SinkConfiguration() = default
SinkConfiguration(std::string name, int level)
auto GetName() const -> const std::string&
virtual auto GetDestination() const -> const std::string& = 0

Protected Functions

virtual auto Configure(boost::log::settings &settings) const -> void

Private Members

std::string name

Friends

friend friend auto initialize_logging_defaults () -> int
friend friend auto initialize_logging (const LoggingConfiguration &logging_configuration) -> void
class SyslogSinkConfiguration : public caosdb::logging::SinkConfiguration

Public Functions

virtual ~SyslogSinkConfiguration() = default
SyslogSinkConfiguration(const std::string &name, int level)
virtual auto GetDestination() const -> const std::string& override

Private Members

const std::string destination = "Syslog"