Commit d0dcc13f authored by gabi's avatar gabi

small cleanup

parent 65a1e569
......@@ -69,25 +69,27 @@ public:
}
}
template<typename T>
void write(const T& what)
{
if (_enabled)
{
_log_msg.raw << what;
}
}
template <typename... Args>
void write(const std::string& fmt, const Args&... args)
{
if (!_enabled)
return;
try
{
_log_msg.raw.write(fmt, args...);
}
catch (const fmt::FormatError& e)
{
throw spdlog_ex(fmt::format("formatting error while processing format string '{}': {}", fmt, e.what()));
}
}
template<typename T>
line_logger& operator<<(const T& what)
{
write(what);
if (_enabled)
_log_msg.raw << what;
return *this;
}
......
......@@ -71,18 +71,7 @@ inline spdlog::details::line_logger spdlog::logger::_log(level::level_enum lvl,
{
bool msg_enabled = should_log(lvl);
details::line_logger l(this, lvl, msg_enabled);
if (msg_enabled)
{
try
{
l.write(fmt, args...);
}
catch(const fmt::FormatError& e)
{
throw spdlog_ex(fmt::format("formatting error while processing format string '{}': {}", fmt, e.what()));
}
}
return l;
}
......@@ -151,7 +140,6 @@ inline spdlog::details::line_logger spdlog::logger::emerg(const std::string& fmt
// //API to support logger.info() << ".." calls
//
inline spdlog::details::line_logger spdlog::logger::_log(level::level_enum lvl)
{
bool msg_enabled = should_log(lvl);
......@@ -213,7 +201,8 @@ inline spdlog::details::line_logger spdlog::logger::emerg()
//
// name and level
//
inline const std::string& spdlog::logger::name() const
{
return _name;
......@@ -239,7 +228,9 @@ inline void spdlog::logger::stop()
_stop();
}
/* protected virtual */
//
// protected virtual called at end of each user log call (if enabled) by the line_logger
//
inline void spdlog::logger::_log_msg(details::log_msg& msg)
{
_formatter->format(msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment