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.
- Multiple Log Levels: Supports
DEBUG,INFO,WARNING,ERROR, andCRITICALlog 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
Loggerclass. - Macro-based Logging: Simplifies logging syntax with macros for different log levels.
- File Logging Support: Introduces the
FileLoggerclass for easy logging to files, enabling persistent log storage and advanced log management strategies.
- C++17 compiler (GCC, Clang, MSVC, etc.)
- Make (optional for building examples)
- CMake (optional)
- Gtest (optional for testing)
- Clone the repository:
git clone https://github.com/araujo88/logtard.git
cd logtard- Include the
logtardlibrary in your C++ project. There's no need to buildlogtardseparately as it's header-only. Just include the relevant headers in your project.
- Include the
ConsoleLoggerin your C++ file:
#include "console_logger.hpp"- Create an instance of
ConsoleLoggerand 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.");- Include the
FileLoggerin your C++ file:
#include "file_logger.hpp"- 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.");cmake -S . -B build
cmake --build buildTo 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.
Contributions are welcome! Please feel free to submit pull requests, report bugs, and suggest features.
This project is licensed under the MIT License - see the LICENSE file for details.