Git Product home page Git Product logo

logtard's Introduction

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.

logtard's People

Contributors

araujo88 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.