Skip to content

A simple cpp logging macro configurable with log levels and output stream.

License

Notifications You must be signed in to change notification settings

exellentcoin26/cpp-log-macro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cpp logging macro

A simple cpp logging macro configurable with log levels and stream output.

Quick start

Copy the log.hpp file to your local project and include it. Or use the repository as a git submodule.

Use case:

#include "log/log.hpp"

#include <iostream>

int main() {
    // Configure the logging macro (only needed once in the application).
    // Note: This is not necessarily needed, because default level and stream
    // are [`LogLevel::Debug`] and [`std::cerr`].
    LOG_CONFIGURE(Warn, std::cout)

    // Log to [`std::cout`] with log level [`LogLevel::Error`].
    LOG(Error) << "An error happened!" << std::endl;

    // Should not be printed because log level is lower than configured log level.
    LOG(Info) << "This should not be displayed..." << std::endl;

    return 0;
}

About

A simple cpp logging macro configurable with log levels and output stream.

Resources

License

Stars

Watchers

Forks

Languages