mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 08:25:43 +08:00
logger class cleanup
This commit is contained in:
parent
c573d2b7ab
commit
0be8981058
@ -90,12 +90,12 @@
|
||||
<ClInclude Include="..\..\include\c11log\factory.h">
|
||||
<Filter>Header Files\c11log</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\c11log\pattern_formatter.h">
|
||||
<Filter>Header Files\c11log\sinks</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\c11log\details\fast_istostr.h">
|
||||
<Filter>Header Files\c11log\details</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\c11log\pattern_formatter.h">
|
||||
<Filter>Header Files\c11log</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
@ -21,7 +21,7 @@ int main(int argc, char* argv[])
|
||||
const unsigned int howmany = argc <= 1 ? 500000 : atoi(argv[1]);
|
||||
|
||||
std::string pattern = "%Y:%m:%d %H:%M:%S.%e [%n:%l] %t";
|
||||
auto formatter1 = std::unique_ptr<formatters::formatter>(new formatters::pattern_formatter(pattern));
|
||||
auto formatter1 = std::unique_ptr<formatter>(new pattern_formatter(pattern));
|
||||
|
||||
logger cout_logger("bench", std::make_shared<sinks::stderr_sink_mt>() , std::move(formatter1));
|
||||
cout_logger.info() << "Hello logger";
|
||||
@ -29,7 +29,7 @@ int main(int argc, char* argv[])
|
||||
auto nullsink = std::make_shared<sinks::null_sink<details::null_mutex>>();
|
||||
|
||||
|
||||
auto formatter2 = std::unique_ptr<formatters::formatter>(new formatters::pattern_formatter(pattern));
|
||||
auto formatter2 = std::unique_ptr<formatter>(new pattern_formatter(pattern));
|
||||
logger my_logger("my_logger", nullsink, std::move(formatter2));
|
||||
//logger my_logger("my_logger", nullsink);
|
||||
|
||||
|
@ -47,22 +47,14 @@ public:
|
||||
const std::string& name() const;
|
||||
bool should_log(level::level_enum) const;
|
||||
|
||||
|
||||
template <typename... Args> details::line_logger log(level::level_enum lvl, const Args&... args);
|
||||
|
||||
template<typename T> details::line_logger trace(const T&);
|
||||
template<typename T> details::line_logger debug(const T&);
|
||||
template <typename... Args> details::line_logger trace(const Args&... args);
|
||||
template <typename... Args> details::line_logger debug(const Args&... args);
|
||||
template <typename... Args> details::line_logger info(const Args&... args);
|
||||
|
||||
template<typename T> details::line_logger warn(const T&);
|
||||
template<typename T> details::line_logger error(const T&);
|
||||
template<typename T> details::line_logger critical(const T&);
|
||||
|
||||
details::line_logger trace();
|
||||
details::line_logger debug();
|
||||
details::line_logger warn();
|
||||
details::line_logger& error();
|
||||
details::line_logger critical();
|
||||
|
||||
template <typename... Args> details::line_logger warn(const Args&... args);
|
||||
template <typename... Args> details::line_logger error(const Args&... args);
|
||||
template <typename... Args> details::line_logger critical(const Args&... args);
|
||||
|
||||
|
||||
|
||||
@ -126,27 +118,10 @@ inline c11log::logger::logger(const std::string& name, It begin, It end, formatt
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline c11log::logger::logger(const std::string& name, sink_ptr sink, formatter_ptr f) :
|
||||
logger(name, {sink}, std::move(f)) {}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
c11log::details::line_logger l(this, level::DEBUG, should_log(level::DEBUG));
|
||||
l.write(msg);
|
||||
return l;
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline c11log::details::line_logger c11log::logger::log(level::level_enum lvl, const Args&... args) {
|
||||
details::line_logger l(this, lvl, true);
|
||||
@ -154,55 +129,35 @@ inline c11log::details::line_logger c11log::logger::log(level::level_enum lvl, c
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
inline c11log::details::line_logger c11log::logger::trace(const Args&... args) {
|
||||
return log(level::TRACE, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline c11log::details::line_logger c11log::logger::debug(const Args&... args) {
|
||||
return log(level::DEBUG, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline c11log::details::line_logger c11log::logger::info(const Args&... args) {
|
||||
details::line_logger l(this, level::INFO, should_log(level::INFO));
|
||||
_variadic_log(l, args...);
|
||||
return l;
|
||||
return log(level::INFO, args...);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline c11log::details::line_logger c11log::logger::warn(const T& msg)
|
||||
{
|
||||
details::line_logger l(this, level::WARNING, should_log(level::WARNING));
|
||||
l.write(msg);
|
||||
return l;
|
||||
template <typename... Args>
|
||||
inline c11log::details::line_logger c11log::logger::warn(const Args&... args) {
|
||||
return log(level::WARNING, args...);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline c11log::details::line_logger c11log::logger::critical(const T& msg)
|
||||
{
|
||||
details::line_logger l(this, level::CRITICAL, should_log(level::CRITICAL));
|
||||
l.write(msg);
|
||||
return l;
|
||||
template <typename... Args>
|
||||
inline c11log::details::line_logger c11log::logger::critical(const Args&... args) {
|
||||
return log(level::CRITICAL, args...);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
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 const std::string& c11log::logger::name() const
|
||||
{
|
||||
return _name;
|
||||
|
Loading…
Reference in New Issue
Block a user