Skip to content

A Fast , Convenient and Lightweight C/C++ Logging Library.

License

Notifications You must be signed in to change notification settings

djoezeke/CLogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Celog 📋

Celog is a lightweight logging library for C/C++ projects. It provides various logging levels and supports colored and styled output for better readability.

Features ✨

  • Multiple log levels:
    • EMERGENCY 🚨
    • ALERT ⚠️
    • CRITICAL ❗
    • ERROR ❌
    • WARNING ⚠️
    • NOTICE 📢
    • INFO ℹ️
    • DEBUG 🐛
  • Colored and styled output 🎨
  • File and function information in log messages 📂
  • Configurable log level, color, and style settings ⚙️

Installation 🛠️

To use Celog in your project, simply include the celog.h header file in your source files.

#include "celog.h"

Usage 📖

Log Levels

Celog provides the following log levels:

  • celog_emerg: Emergency messages 🚨
  • celog_alert: Alert messages ⚠️
  • celog_crit: Critical messages ❗
  • celog_error: Error messages ❌
  • celog_warn: Warning messages ⚠️
  • celog_notice: Notice messages 📢
  • celog_info: Informational messages ℹ️
  • celog_debug: Debug messages 🐛

Example

#include "celog.h"

int main() {
    celog_emerg("This is an emergency message");
    celog_alert("This is an alert message");
    celog_crit("This is a critical message");
    celog_error("This is an error message");
    celog_warn("This is a warning message");
    celog_notice("This is a notice message");
    celog_info("This is an informational message");
    celog_debug("This is a debug message");

    return 0;
}

Configuration ⚙️

You can configure the log level, color, and style settings by defining or uncommenting the following macros in ceconfig.h:

  • CELOG_LOG_LEVEL: Set the log level (default: 7)
  • CELOG_COLOR: Enable or disable colored output (default: 1)
  • CELOG_STYLE: Enable or disable styled output (default: 1)

Example Configuration

To customize the logging behavior, you can modify the ceconfig.h file:

// Set the log level to WARNING
#define CELOG_LOG_LEVEL 4

// Disable file information in log messages
#define CELOG_NO_FILE_INFO

// Disable function information in log messages
#define CELOG_NO_FUNC_INFO

Log Level Controls

Celog allows you to control the log levels by defining the CELOG_LOG_LEVEL macro. Messages with a log level lower than the defined level will be disabled.

Log Information Controls

Celog allows you to control the log information by defining:

  • CELOG_NO_FILE_INFO: Disables logging of file information (file name and line number).
  • CELOG_NO_FUNC_INFO: Disables logging of function information (function name).

Color and Style Controls

You can disable colors and styles by setting CELOG_COLOR and CELOG_STYLE to 0, respectively.

License 📄

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing 🤝

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Acknowledgements 🙏

Celog is inspired by various logging libraries and aims to provide a simple and lightweight solution for C/C++ projects.

Releases

No releases published

Packages

No packages published

Languages