13 #define SPDLOG_CATCH_AND_HANDLE \ 14 catch (const std::exception &ex) \ 16 err_handler_(ex.what()); \ 20 err_handler_("Unknown exception in logger"); \ 27 : name_(
std::move(logger_name))
40 :
logger(
std::move(logger_name), {std::move(single_sink)})
50 sink->set_formatter(f->clone());
56 auto new_formatter = details::make_unique<spdlog::pattern_formatter>(std::move(pattern), time_type);
60 template<
typename... Args>
79 template<
typename... Args>
111 template<class T, typename std::enable_if<std::is_convertible<T, spdlog::string_view_t>::value, T>
::type *>
126 template<class T, typename std::enable_if<!std::is_convertible<T, spdlog::string_view_t>::value, T>
::type *>
144 template<
typename... Args>
150 template<
typename... Args>
156 template<
typename... Args>
162 template<
typename... Args>
168 template<
typename... Args>
174 template<
typename... Args>
216 #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT 220 int wbuf_size =
static_cast<int>(wbuf.
size());
226 auto result_size = ::WideCharToMultiByte(CP_UTF8, 0, wbuf.
data(), wbuf_size, NULL, 0, NULL, NULL);
230 target.
resize(result_size);
231 ::WideCharToMultiByte(CP_UTF8, 0, wbuf.
data(), wbuf_size, &target.
data()[0], result_size, NULL, NULL);
239 template<
typename... Args>
254 wbuf_to_utf8buf(wbuf, buf);
261 template<
typename... Args>
267 template<
typename... Args>
273 template<
typename... Args>
279 template<
typename... Args>
285 template<
typename... Args>
291 template<
typename... Args>
297 template<
typename... Args>
303 #endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT 365 return msg_level >=
level_.load(std::memory_order_relaxed);
374 #if defined(SPDLOG_ENABLE_MESSAGE_COUNTER) 379 if (sink->should_log(msg.
level))
401 auto now = time(
nullptr);
409 std::strftime(date_buf,
sizeof(date_buf),
"%Y-%m-%d %H:%M:%S", &tm_time);
410 fmt::print(stderr,
"[*** LOG ERROR ***] [{}] [{}] {}\n", date_buf,
name(), msg);
430 auto cloned = std::make_shared<spdlog::logger>(std::move(logger_name),
sinks_.begin(),
sinks_.end());
431 cloned->set_level(this->
level());
auto begin(const C &c) -> decltype(c.begin())
level::level_enum flush_level() const
std::atomic< time_t > last_err_time_
std::enable_if< internal::is_string< String >::value >::type print(std::FILE *f, const text_style &ts, const String &format_str, const Args &...args)
void incr_msg_counter_(details::log_msg &msg)
void error(const char *fmt, const Args &...args)
log_err_handler error_handler() const
std::initializer_list< sink_ptr > sinks_init_list
void warn(const char *fmt, const Args &...args)
log_err_handler err_handler_
spdlog::log_clock::time_point now() noexcept
std::atomic< size_t > msg_counter_
void log(level::level_enum lvl, const char *fmt, const Args &...args)
void info(const char *fmt, const Args &...args)
std::tm localtime(const std::time_t &time_tt) noexcept
#define SPDLOG_CATCH_AND_HANDLE
const std::vector< sink_ptr > & sinks() const
std::shared_ptr< sinks::sink > sink_ptr
void set_pattern(std::string pattern, pattern_time_type time_type=pattern_time_type::local)
static level::level_enum default_level()
std::vector< sink_ptr > sinks_
bool should_flush_(const details::log_msg &msg)
void resize(std::size_t new_size)
void default_err_handler_(const std::string &msg)
void critical(const char *fmt, const Args &...args)
virtual std::shared_ptr< logger > clone(std::string logger_name)
std::basic_string< typename char_t< S >::type > format(const S &format_str, const Args &...args)
void debug(const char *fmt, const Args &...args)
bool should_log(level::level_enum msg_level) const
spdlog::level_t flush_level_
string_view_t & to_string_view(spdlog::level::level_enum l) noexcept
level::level_enum level() const
void set_formatter(std::unique_ptr< formatter > formatter)
void trace(const char *fmt, const Args &...args)
std::enable_if< is_contiguous< Container >::value &&internal::is_string< S >::value, std::back_insert_iterator< Container > >::type format_to(std::back_insert_iterator< Container > out, const S &format_str, const Args &...args)
void set_error_handler(log_err_handler err_handler)
const std::string & name() const
spdlog::string_view_t to_string_view(const fmt::basic_memory_buffer< char, Buffer_Size > &buf) SPDLOG_NOEXCEPT
std::size_t strftime(char *str, std::size_t count, const char *format, const std::tm *time)
std::function< void(const std::string &err_msg)> log_err_handler
logger(std::string name, sink_ptr single_sink)
#define SPDLOG_ACTIVE_LEVEL
auto end(const C &c) -> decltype(c.end())
void set_level(level::level_enum log_level)
void flush_on(level::level_enum log_level)
virtual void sink_it_(details::log_msg &msg)