CppLogging  1.0.4.0
C++ Logging Library
file.cpp

File logger example

#include "logging/config.h"
#include "logging/logger.h"
void ConfigureLogger()
{
// Create default logging sink processor with a binary layout
auto sink = std::make_shared<CppLogging::Processor>(std::make_shared<CppLogging::BinaryLayout>());
// Add file appender
sink->appenders().push_back(std::make_shared<CppLogging::FileAppender>("file.bin.log"));
// Configure example logger
// Startup the logging infrastructure
}
int main(int argc, char** argv)
{
// Configure logger
ConfigureLogger();
// Create example logger
CppLogging::Logger logger("example");
// Log some messages with different level
logger.Debug("Debug message {}", 1);
logger.Info("Info message {}", 2);
logger.Warn("Warning message {}", 3);
logger.Error("Error message {}", 4);
logger.Fatal("Fatal message {}", 5);
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
Logger configuration definition.
Logger interface definition.