Skip to content

04doom/Chromalog

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Chromalog

A modern C++ logging library with colored output and simple formatting

Features

  • 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

Installation

Download chromalog.h and include it in project:

#include "chromalog.h"

Get started

#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;
}

Logging levels

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 license
  • warning -> warning about potential issues.
  • error -> error conditions that does not stop exeucution.
  • critical -> critical error that MAY stop execution.
  • off -> disable all logging.

Config

auto logger = create_logger("app", chromalog::debug, true);
logger->set_level(chromalog::warning);
logger->set_colors(false);

API refrence

Create logger instance

// 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);

Log methods

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);

Utility methods

logger->set_level(level);      // minimum log level threshold
logger->set_colors(enable);    // disable/enable colored output
logger->get_level();           // returns current log level 

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

Global log

For quick logging without creating a logger instance, you can use this:

get_logger().log_info("message: {}", value);

Platform Support

  • Linux/macOS: Colors work in all standard terminals
  • Windows: Colors work in Windows 10+ CMD, PowerShell

License

MIT License - See LICENSE file for details. if you encounter any issues, feel free to add me on discord - oi2qq Thanks for using!

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 100.0%