A modern C++ logging library with colored output and simple formatting
- Color coded log levels for better readability
- Precise timestamps with millisecond precision
- Easy message formatting with
{}
placeholders - Single header file implementation
- Support for Linux, Windows, and MacOS
- Lightweight and fast
Download chromalog.h
and include it in project:
#include "chromalog.h"
#include "chromalog.h"
#include <memory>
int main() {
auto logger = create_logger("veryproniceapplication");
logger->log_info("started, this was made by bitflags");
logger->log_debug("processing something: {}", 00);
logger->log_warning("cpu usage --placeholder: {}%", 00);
logger->log_error("could not initalize: {}", "timeout");
logger->log_critical("very nice error idk:{}", "fatal");
return 0;
}
Chromalog supports the following log levels in order of severity.
trace
-> very detailed diagnostic info.debug
-> detailed diagnostic info for debugging.info
-> general message, e.g make sure to read the licensewarning
-> warning about potential issues.error
-> error conditions that does not stop exeucution.critical
-> critical error that MAY stop execution.off
-> disable all logging.
auto logger = create_logger("app", chromalog::debug, true);
logger->set_level(chromalog::warning);
logger->set_colors(false);
// creats a logger with default parameters (info level, colors enabled)
auto logger = create_logger("name");
// create with custom level and color settings
auto logger = create_logger("name", chromalog::debug, true);
logger->log_trace("Detailed info: {}", value);
logger->log_debug("Debug info: {}", value);
logger->log_info("hi {}", value);
logger->log_warning("Warning: {}", message);
logger->log_error("Error: {}", message);
logger->log_critical("Critical: {}", message);
logger->set_level(level); // minimum log level threshold
logger->set_colors(enable); // disable/enable colored output
logger->get_level(); // returns current log level
Log levels follow this:
trace < debug < info < warning < error < critical < off
setting a log level will display that level and all levels above it
For quick logging without creating a logger instance, you can use this:
get_logger().log_info("message: {}", value);
- Linux/macOS: Colors work in all standard terminals
- Windows: Colors work in Windows 10+ CMD, PowerShell
MIT License - See LICENSE file for details. if you encounter any issues, feel free to add me on discord - oi2qq Thanks for using!