CppLogging  1.0.4.0
C++ Logging Library
console.cpp

Console logger example

#include "logging/config.h"
#include "logging/logger.h"
void ConfigureLogger()
{
// Create default logging sink processor with a text layout
auto sink = std::make_shared<CppLogging::Processor>(std::make_shared<CppLogging::TextLayout>());
// Add console appender
sink->appenders().push_back(std::make_shared<CppLogging::ConsoleAppender>());
// Configure default logger
// Startup the logging infrastructure
}
int main(int argc, char** argv)
{
// Configure logger
ConfigureLogger();
// Create default logger
// Log some messages with different level
logger.Debug("Debug message");
logger.Info("Info message");
logger.Warn("Warning message");
logger.Error("Error message");
logger.Fatal("Fatal message");
return 0;
}
static void ConfigLogger(const std::shared_ptr< Processor > &sink)
Configure default logger with a given logging sink processor.
Definition: config.cpp:19
static void Startup()
Startup the logging infrastructure.
Definition: config.cpp:68
Logger interface.
Definition: logger.h:23
void Warn(std::string_view message) const
Log warning message.
Definition: logger.h:75
void Debug(std::string_view message) const
Log debug message.
Definition: logger.h:47
void Fatal(std::string_view message) const
Log fatal message.
Definition: logger.h:101
void Error(std::string_view message) const
Log error message.
Definition: logger.h:88
void Info(std::string_view message) const
Log information message.
Definition: logger.h:62
Logger configuration definition.
Logger interface definition.