Skip to content

A simple, portable and dumb logging library in C++ with no bloatness nor mambo-jambo

License

Notifications You must be signed in to change notification settings

araujo88/logtard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logtard Logging Library

license build

The Logtard Logging Library provides a flexible and easy-to-use logging system for C++ applications. It supports multiple log levels and can be extended to log messages to various outputs, with the default implementation focusing on console output with colored log levels for enhanced readability.

Features

  • Multiple Log Levels: Supports DEBUG, INFO, WARNING, ERROR, and CRITICAL log levels to suit different verbosity needs.
  • Colored Output: Enhances log readability in the console with colored log levels.
  • Extensible Design: Designed with extensibility in mind, allowing for the implementation of additional loggers by extending the base Logger class.
  • Macro-based Logging: Simplifies logging syntax with macros for different log levels.
  • File Logging Support: Introduces the FileLogger class for easy logging to files, enabling persistent log storage and advanced log management strategies.

Getting Started

Prerequisites

  • C++17 compiler (GCC, Clang, MSVC, etc.)
  • Make (optional for building examples)
  • CMake (optional)
  • Gtest (optional for testing)

Installation

  1. Clone the repository:
git clone https://github.com/araujo88/logtard.git
cd logtard
  1. Include the logtard library in your C++ project. There's no need to build logtard separately as it's header-only. Just include the relevant headers in your project.

Usage

Console Logging

  1. Include the ConsoleLogger in your C++ file:
#include "console_logger.hpp"
  1. Create an instance of ConsoleLogger and use the provided macros to log messages:
logtard::ConsoleLogger logger;
LOG_INFO(logger, "This is an informational message.");
LOG_ERROR(logger, "This is an error message.");

File Logging

  1. Include the FileLogger in your C++ file:
#include "file_logger.hpp"
  1. Create an instance of FileLogger, specifying the log file path:
logtard::FileLogger logger("application.log");
LOG_INFO(logger, "This is an informational message logged to a file.");
LOG_ERROR(logger, "This is an error message logged to a file.");

Building project with CMake

cmake -S . -B build
cmake --build build

Extending Logtard

To create a custom logger, extend the Logger class and implement the log method. Refer to console_logger.hpp and console_logger.cpp for implementation examples.

Contributing

Contributions are welcome! Please feel free to submit pull requests, report bugs, and suggest features.

License

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

About

A simple, portable and dumb logging library in C++ with no bloatness nor mambo-jambo

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published