This commit is contained in:
gabime 2014-03-29 01:38:05 +03:00
parent 87cc555d0b
commit f090d66066
4 changed files with 27 additions and 27 deletions

View File

@ -20,8 +20,8 @@ int main(int argc, char* argv[])
const unsigned int howmany = argc <= 1 ? 1000:atoi(argv[1]); const unsigned int howmany = argc <= 1 ? 1000:atoi(argv[1]);
logger cout_logger ("", sinks::stdout_sink()); logger cout_logger ("", sinks::stdout_sink());
cout_logger.info("Hello ") << "man"; cout_logger.info("Hello ") << "man";
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);

View File

@ -25,7 +25,7 @@ public:
{ {
if(enabled) if(enabled)
{ {
_log_msg.msg_time = log_clock::now(); _log_msg.msg_time = log_clock::now();
callback_logger->_formatter->format_header(callback_logger->_logger_name, callback_logger->_formatter->format_header(callback_logger->_logger_name,
_log_msg.msg_level, _log_msg.msg_level,
_log_msg.msg_time, _log_msg.msg_time,
@ -56,7 +56,7 @@ public:
_callback_logger->_log_it(_log_msg); _callback_logger->_log_it(_log_msg);
} }
} }
template<typename T> template<typename T>
line_logger& operator<<(const T& what) line_logger& operator<<(const T& what)
{ {

View File

@ -35,7 +35,7 @@ public:
using sinks_init_list = std::initializer_list<sink_ptr>; using sinks_init_list = std::initializer_list<sink_ptr>;
logger(const std::string& name, sinks_init_list, formatter_ptr = nullptr); logger(const std::string& name, sinks_init_list, formatter_ptr = nullptr);
logger(const std::string& name, sink_ptr, formatter_ptr = nullptr); logger(const std::string& name, sink_ptr, formatter_ptr = nullptr);
~logger() = default; ~logger() = default;
@ -56,7 +56,7 @@ public:
template<typename T> details::line_logger info(const T&); template<typename T> details::line_logger info(const T&);
template<typename T> details::line_logger warn(const T&); template<typename T> details::line_logger warn(const T&);
template<typename T> details::line_logger error(const T&); template<typename T> details::line_logger error(const T&);
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&);
@ -89,13 +89,13 @@ inline c11log::logger::logger(const std::string& name, sinks_init_list sinks_lis
{ {
//Seems that vs2013 doesnt support std::atomic member initialization, so its done here //Seems that vs2013 doesnt support std::atomic member initialization, so its done here
_logger_level = level::INFO; _logger_level = level::INFO;
if(!_formatter) if(!_formatter)
_formatter = std::make_shared<formatters::default_formatter>(); _formatter = std::make_shared<formatters::default_formatter>();
} }
inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_ptr f) : inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_ptr f) :
logger(name, {sink}, f) {} logger(name, {sink}, f) {}
inline c11log::details::line_logger c11log::logger::log(c11log::level::level_enum msg_level) inline c11log::details::line_logger c11log::logger::log(c11log::level::level_enum msg_level)
{ {
@ -108,8 +108,8 @@ inline c11log::details::line_logger c11log::logger::debug(const T& what)
{ {
bool really_log = should_log(level::DEBUG); bool really_log = should_log(level::DEBUG);
details::line_logger l(this, level::DEBUG, really_log); details::line_logger l(this, level::DEBUG, really_log);
if(really_log) if(really_log)
l << what; l << what;
return l; return l;
} }
@ -118,8 +118,8 @@ inline c11log::details::line_logger c11log::logger::info(const T& what)
{ {
bool really_log = should_log(level::INFO); bool really_log = should_log(level::INFO);
details::line_logger l(this, level::INFO, really_log); details::line_logger l(this, level::INFO, really_log);
if(really_log) if(really_log)
l << what; l << what;
return l; return l;
} }
@ -129,8 +129,8 @@ inline c11log::details::line_logger c11log::logger::warn(const T& what)
{ {
bool really_log = should_log(level::WARNING); bool really_log = should_log(level::WARNING);
details::line_logger l(this, level::WARNING, really_log); details::line_logger l(this, level::WARNING, really_log);
if(really_log) if(really_log)
l << what; l << what;
return l; return l;
} }
@ -140,8 +140,8 @@ inline c11log::details::line_logger c11log::logger::error(const T& what)
{ {
bool really_log = should_log(level::ERROR); bool really_log = should_log(level::ERROR);
details::line_logger l(this, level::ERROR, really_log); details::line_logger l(this, level::ERROR, really_log);
if(really_log) if(really_log)
l << what; l << what;
return l; return l;
} }
@ -151,18 +151,18 @@ inline c11log::details::line_logger c11log::logger::critical(const T& what)
{ {
bool really_log = should_log(level::CRITICAL); bool really_log = should_log(level::CRITICAL);
details::line_logger l(this, level::CRITICAL, really_log); details::line_logger l(this, level::CRITICAL, really_log);
if(really_log) if(really_log)
l << what; l << what;
return l; return l;
} }
template<typename T> template<typename T>
inline c11log::details::line_logger c11log::logger::fatal(const T& what) inline c11log::details::line_logger c11log::logger::fatal(const T& what)
{ {
bool really_log = should_log(level::FATAL); bool really_log = should_log(level::FATAL);
details::line_logger l(this, level::FATAL, really_log); details::line_logger l(this, level::FATAL, really_log);
if(really_log) if(really_log)
l << what; l << what;
return l; return l;
} }

View File

@ -46,11 +46,11 @@ protected:
class null_sink:public base_sink class null_sink:public base_sink
{ {
public: public:
static std::shared_ptr<null_sink>& get() static std::shared_ptr<null_sink>& get()
{ {
static auto inst = std::make_shared<null_sink>(); static auto inst = std::make_shared<null_sink>();
return inst; return inst;
} }
protected: protected:
void _sink_it(const details::log_msg&) override void _sink_it(const details::log_msg&) override
{} {}