Commit fff6d8f3 authored by gabime's avatar gabime

nice logger api improvement

parent 1a795a44
......@@ -21,7 +21,7 @@ int main(int argc, char* argv[])
const unsigned int howmany = argc <= 1 ? 1000000:atoi(argv[1]);
logger cout_logger ("", sinks::stdout_sink());
cout_logger.info("Hello ") << "man" << 123 << " : " << 0.45f;
cout_logger.info() << "Hello " << "man" << 123 << " : " << 0.45f;
cout_logger.info("This is very nice! ") << "Yes gabi.." << ":)";
auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0);
......
......@@ -57,6 +57,13 @@ public:
template<typename T> details::line_logger critical(const T&);
template<typename T> details::line_logger fatal(const T&);
details::line_logger debug();
details::line_logger info();
details::line_logger warn();
details::line_logger error();
details::line_logger critical();
details::line_logger fatal();
private:
friend details::line_logger;
......@@ -139,6 +146,32 @@ inline c11log::details::line_logger c11log::logger::fatal(const T& msg)
return l;
}
inline c11log::details::line_logger c11log::logger::debug()
{
return details::line_logger(this, level::DEBUG, should_log(level::DEBUG));
}
inline c11log::details::line_logger c11log::logger::info()
{
return details::line_logger(this, level::INFO, should_log(level::INFO));
}
inline c11log::details::line_logger c11log::logger::warn()
{
return details::line_logger(this, level::WARNING, should_log(level::WARNING));
}
inline c11log::details::line_logger c11log::logger::critical()
{
return details::line_logger(this, level::CRITICAL, should_log(level::CRITICAL));
}
inline c11log::details::line_logger c11log::logger::fatal()
{
return details::line_logger(this, level::FATAL, should_log(level::FATAL));
}
inline const std::string& c11log::logger::get_name() const
{
return _logger_name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment