mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
added trace log level
This commit is contained in:
parent
36ef0732b3
commit
4696132cd5
@ -21,8 +21,9 @@ int main(int argc, char* argv[])
|
||||
const unsigned int howmany = argc <= 1 ? 1000000:atoi(argv[1]);
|
||||
|
||||
logger cout_logger ("", sinks::stdout_sink());
|
||||
cout_logger.set_min_level(c11log::level::TRACE);
|
||||
cout_logger.info() << "Hello " << "man" << 123;
|
||||
cout_logger.info("This is very nice! ") << "Yes gabi.." << ":)";
|
||||
cout_logger.trace("This is very nice! ") << "Yes gabi.." << ":)";
|
||||
|
||||
auto fsink = std::make_shared<sinks::rotating_file_sink>("log", "txt", 1024*1024*50 , 5, 0);
|
||||
auto nullsink = sinks::null_sink::get();
|
||||
|
@ -12,6 +12,7 @@ namespace level
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
TRACE,
|
||||
DEBUG,
|
||||
INFO,
|
||||
WARNING,
|
||||
@ -21,7 +22,7 @@ typedef enum
|
||||
NONE = 99
|
||||
} level_enum;
|
||||
|
||||
static const char* level_names[] { "debug", "info", "warning", "error", "critical", "fatal" };
|
||||
static const char* level_names[] { "trace", "debug", "info", "warning", "error", "critical", "fatal" };
|
||||
inline const char* to_str(c11log::level::level_enum l)
|
||||
{
|
||||
return level_names[l];
|
||||
|
@ -49,7 +49,8 @@ public:
|
||||
|
||||
const std::string& get_name() const;
|
||||
bool should_log(c11log::level::level_enum) const;
|
||||
|
||||
|
||||
template<typename T> details::line_logger trace(const T&);
|
||||
template<typename T> details::line_logger debug(const T&);
|
||||
template<typename T> details::line_logger info(const T&);
|
||||
template<typename T> details::line_logger warn(const T&);
|
||||
@ -57,6 +58,8 @@ public:
|
||||
template<typename T> details::line_logger critical(const T&);
|
||||
template<typename T> details::line_logger fatal(const T&);
|
||||
|
||||
|
||||
details::line_logger trace();
|
||||
details::line_logger debug();
|
||||
details::line_logger info();
|
||||
details::line_logger warn();
|
||||
@ -106,6 +109,14 @@ inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_
|
||||
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline c11log::details::line_logger c11log::logger::trace(const T& msg)
|
||||
{
|
||||
details::line_logger l(this, level::TRACE, should_log(level::TRACE));
|
||||
l.write(msg);
|
||||
return l;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline c11log::details::line_logger c11log::logger::debug(const T& msg)
|
||||
{
|
||||
@ -146,6 +157,12 @@ inline c11log::details::line_logger c11log::logger::fatal(const T& msg)
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
inline c11log::details::line_logger c11log::logger::trace()
|
||||
{
|
||||
return details::line_logger(this, level::TRACE, should_log(level::TRACE));
|
||||
}
|
||||
|
||||
inline c11log::details::line_logger c11log::logger::debug()
|
||||
{
|
||||
return details::line_logger(this, level::DEBUG, should_log(level::DEBUG));
|
||||
|
Loading…
Reference in New Issue
Block a user