linkahead/logging.h
Defines
-
LINKAHEAD_LOG_FATAL(Channel)
-
LINKAHEAD_LOG_ERROR(Channel)
-
LINKAHEAD_LOG_WARN(Channel)
-
LINKAHEAD_LOG_INFO(Channel)
-
LINKAHEAD_LOG_DEBUG(Channel)
-
LINKAHEAD_LOG_TRACE(Channel)
-
LINKAHEAD_LOG_TRACE_ENTER_AND_LEAVE(Channel, FunctionName)
-
LINKAHEAD_LOG_ERROR_AND_RETURN_STATUS(Channel, StatusCode, Message)
-
namespace linkahead
-
namespace logging
Functions
-
auto initialize_logging_defaults() -> int
-
auto initialize_logging(const LoggingConfiguration &configuration) -> void
-
void linkahead_log_fatal(const char *channel, const char *msg)
Convenience function for the C interface.
-
void linkahead_log_error(const char *channel, const char *msg)
Convenience function for the C interface.
-
void linkahead_log_warn(const char *channel, const char *msg)
Convenience function for the C interface.
-
void linkahead_log_info(const char *channel, const char *msg)
Convenience function for the C interface.
-
void linkahead_log_debug(const char *channel, const char *msg)
Convenience function for the C interface.
-
void linkahead_log_trace(const char *channel, const char *msg)
Convenience function for the C interface.
Variables
-
const std::string logger_name = "linkahead::logging"
-
class ConsoleSinkConfiguration : public linkahead::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(void *settings) const -> void override
Private Members
-
const std::string destination = "Console"
Friends
-
friend auto initialize_logging_defaults() -> int
-
friend auto initialize_logging(const LoggingConfiguration &logging_configuration) -> void
-
virtual ~ConsoleSinkConfiguration() = default
-
class FileSinkConfiguration : public linkahead::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(void *settings) const -> void override
Friends
-
friend auto initialize_logging_defaults() -> int
-
friend auto initialize_logging(const LoggingConfiguration &logging_configuration) -> void
-
virtual ~FileSinkConfiguration() = default
-
class LevelConfiguration
- #include <logging.h>
This class stores the integer log level.
Subclassed by linkahead::logging::LoggingConfiguration, linkahead::logging::SinkConfiguration
Private Members
-
int level
-
int level
-
class LoggerOutputStream
Public Functions
-
LoggerOutputStream(std::string channel, int level)
-
auto operator<<(std::ostream &(*f)(std::ostream&)) -> LoggerOutputStream&
-
auto operator<<(bool msg) -> LoggerOutputStream&
-
auto operator<<(int msg) -> LoggerOutputStream&
-
auto operator<<(uint64_t msg) -> LoggerOutputStream&
-
auto operator<<(int64_t msg) -> LoggerOutputStream&
-
auto operator<<(std::streambuf *msg) -> LoggerOutputStream&
-
auto operator<<(const char *msg) -> LoggerOutputStream&
-
auto operator<<(const std::string &msg) -> LoggerOutputStream&
-
auto operator<<(void *msg) -> LoggerOutputStream&
-
auto operator<<(std::filesystem::path *path) -> LoggerOutputStream&
-
auto operator<<(const std::filesystem::path &path) -> LoggerOutputStream&
Public Static Functions
-
static inline auto get(const std::string &channel, int level) -> LoggerOutputStream
-
LoggerOutputStream(std::string channel, int level)
-
class LoggingConfiguration : public linkahead::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 GetSinks() const -> const std::vector<std::shared_ptr<SinkConfiguration>>&
Private Members
-
std::vector<std::shared_ptr<SinkConfiguration>> sinks
-
virtual ~LoggingConfiguration() = default
-
class SinkConfiguration : public linkahead::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
level
keyword sets the logging level, if it exists at the sink or logging level of the configuration.Subclassed by linkahead::logging::ConsoleSinkConfiguration, linkahead::logging::FileSinkConfiguration, linkahead::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(void *settings) const -> void
Private Members
-
std::string name
Friends
-
friend auto initialize_logging_defaults() -> int
-
friend auto initialize_logging(const LoggingConfiguration &logging_configuration) -> void
-
class SyslogSinkConfiguration : public linkahead::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"
-
virtual ~SyslogSinkConfiguration() = default
-
class TraceEnterLeaveLogger
- #include <logging.h>
Helper class for logging the entering and leaving of a function or method.
Please Use the macro
LINKAHEAD_LOG_TRACE_ENTER_AND_LEAVE(logger_name, function_name);
-
auto initialize_logging_defaults() -> int
-
namespace logging