mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 10:01:33 +08:00
nice logger api improvement
This commit is contained in:
parent
1a795a44de
commit
fff6d8f388
@ -21,7 +21,7 @@ int main(int argc, char* argv[])
|
|||||||
const unsigned int howmany = argc <= 1 ? 1000000:atoi(argv[1]);
|
const unsigned int howmany = argc <= 1 ? 1000000:atoi(argv[1]);
|
||||||
|
|
||||||
logger cout_logger ("", sinks::stdout_sink());
|
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.." << ":)";
|
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);
|
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 critical(const T&);
|
||||||
template<typename T> details::line_logger fatal(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:
|
private:
|
||||||
friend details::line_logger;
|
friend details::line_logger;
|
||||||
@ -139,6 +146,32 @@ inline c11log::details::line_logger c11log::logger::fatal(const T& msg)
|
|||||||
return l;
|
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
|
inline const std::string& c11log::logger::get_name() const
|
||||||
{
|
{
|
||||||
return _logger_name;
|
return _logger_name;
|
||||||
|
Loading…
Reference in New Issue
Block a user