Skip to content

A C++ stream (std::cout, std::clog, std::cerr, etc) log redirector to be used together with spdlog

License

Notifications You must be signed in to change notification settings

oxavelar/streamlog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

streamlog

A C++ stream (std::cout, std::clog, std::cerr, etc) log redirector to be used together with spdlog.

example

Here is an example for redirecting the 3 streams of "cout", "clog", "cerr" into a console screen and a logfile:

#include "streamlog.hpp"

#define appname "hello_world"
#define logfile "hello_world.log"
 
auto screen = spdlog::stdout_color_st("console");
auto logger = spdlog::basic_logger_st("logfile", logfile);

spdlog::set_pattern("[%H:%M:%S.%e] %L: " appname ": %v");

screen->set_level(spdlog::level::debug);
logger->set_level(spdlog::level::debug);

streamlog redirector_cout(std::cout, streamlog::loglevel::info);
streamlog redirector_clog(std::clog, streamlog::loglevel::debug);
streamlog redirector_cerr(std::cerr, streamlog::loglevel::error);

std::cout << std::nounitbuf;
std::clog << std::nounitbuf;
std::cerr << std::nounitbuf;

About

A C++ stream (std::cout, std::clog, std::cerr, etc) log redirector to be used together with spdlog

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages