nice logger api improvement

This commit is contained in:
gabime 2014-03-31 02:24:11 +03:00
parent 1a795a44de
commit fff6d8f388
2 changed files with 34 additions and 1 deletions

View File

@ -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);

View File

@ -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;