Agora
1.2.0
Agora project
|
Go to the documentation of this file.
6 #ifndef SPDLOG_HEADER_ONLY
21 , sinks_(other.sinks_)
22 , level_(other.level_.
load(
std::memory_order_relaxed))
23 , flush_level_(other.flush_level_.
load(
std::memory_order_relaxed))
24 , custom_err_handler_(other.custom_err_handler_)
25 , tracer_(other.tracer_)
29 sinks_(std::move(other.sinks_)),
30 level_(other.level_.load(std::memory_order_relaxed)),
31 flush_level_(other.flush_level_.load(std::memory_order_relaxed)),
32 custom_err_handler_(std::move(other.custom_err_handler_)),
33 tracer_(std::move(other.tracer_))
45 name_.swap(other.name_);
46 sinks_.swap(other.sinks_);
49 auto other_level = other.level_.load();
50 auto my_level = level_.exchange(other_level);
51 other.level_.store(my_level);
54 other_level = other.flush_level_.load();
55 my_level = flush_level_.exchange(other_level);
56 other.flush_level_.store(my_level);
58 custom_err_handler_.swap(other.custom_err_handler_);
88 if (std::next(it) ==
sinks_.end())
91 (*it)->set_formatter(std::move(f));
96 (*it)->set_formatter(f->clone());
103 auto new_formatter = details::make_unique<pattern_formatter>(std::move(pattern), time_type);
160 auto cloned = std::make_shared<logger>(*
this);
161 cloned->name_ = std::move(logger_name);
172 if (traceback_enabled)
182 if (sink->should_log(msg.
level))
235 using std::chrono::system_clock;
236 static std::mutex mutex;
237 static std::chrono::system_clock::time_point last_report_time;
238 static size_t err_counter = 0;
239 std::lock_guard<std::mutex> lk{mutex};
242 if (
now - last_report_time < std::chrono::seconds(1))
246 last_report_time =
now;
249 std::strftime(date_buf,
sizeof(date_buf),
"%Y-%m-%d %H:%M:%S", &tm_time);
250 #if defined(USING_R) && defined(R_R_H) // if in R environment
251 REprintf(
"[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf,
name().c_str(), msg.c_str());
253 std::fprintf(stderr,
"[*** LOG ERROR #%04zu ***] [%s] [%s] {%s}\n", err_counter, date_buf,
name().c_str(), msg.c_str());
bool should_flush_(const details::log_msg &msg)
Definition: logger-inl.h:221
logger(std::string name)
Definition: logger.h:58
std::vector< sink_ptr > sinks_
Definition: logger.h:348
#define SPDLOG_NOEXCEPT
Definition: common.h:64
virtual std::shared_ptr< logger > clone(std::string logger_name)
Definition: logger-inl.h:158
#define SPDLOG_LOGGER_CATCH(location)
Definition: logger.h:31
@ off
Definition: common.h:219
spdlog::level_t flush_level_
Definition: logger.h:350
void set_formatter(std::unique_ptr< formatter > f)
Definition: logger-inl.h:84
err_handler custom_err_handler_
Definition: logger.h:351
details::backtracer tracer_
Definition: logger.h:352
void disable_backtrace()
Definition: logger-inl.h:114
void log_it_(const details::log_msg &log_msg, bool log_enabled, bool traceback_enabled)
Definition: logger-inl.h:166
@ info
Definition: common.h:215
void swap(nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType > &j1, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType > &j2) noexcept(//NOLINT(readability-inconsistent-declaration-parameter-name) is_nothrow_move_constructible< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType > >::value &&//NOLINT(misc-redundant-expression) is_nothrow_move_assignable< nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer, BinaryType > >::value)
exchanges the values of two JSON objects
Definition: json.hpp:24114
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT
Definition: os-inl.h:71
level_enum
Definition: common.h:211
void set_level(level::level_enum log_level)
Definition: logger-inl.h:67
void enable_backtrace(size_t n_messages)
Definition: logger-inl.h:108
void dump_backtrace()
Definition: logger-inl.h:119
std::string name_
Definition: logger.h:347
SPDLOG_INLINE void swap(logger &a, logger &b)
Definition: logger-inl.h:62
void flush()
Definition: logger-inl.h:125
bool enabled() const
Definition: backtracer-inl.h:46
spdlog::level_t level_
Definition: logger.h:349
level::level_enum level() const
Definition: logger-inl.h:72
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT
Definition: os-inl.h:84
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
Definition: printf.h:607
#define SPDLOG_INLINE
Definition: common.h:42
level::level_enum level
Definition: log_msg.h:21
const std::vector< sink_ptr > & sinks() const
Definition: logger-inl.h:141
std::function< void(const std::string &err_msg)> err_handler
Definition: common.h:129
void foreach_pop(std::function< void(const details::log_msg &)> fun)
Definition: backtracer-inl.h:58
void dump_backtrace_()
Definition: logger-inl.h:210
void flush_on(level::level_enum log_level)
Definition: logger-inl.h:130
const std::string & name() const
Definition: logger-inl.h:77
pattern_time_type
Definition: common.h:267
Definition: json.hpp:5213
virtual void sink_it_(const details::log_msg &msg)
Definition: logger-inl.h:178
void set_error_handler(err_handler)
Definition: logger-inl.h:152
void push_back(const log_msg &msg)
Definition: backtracer-inl.h:51
void enable(size_t size)
Definition: backtracer-inl.h:33
virtual void flush_()
Definition: logger-inl.h:198
end load("results.mat") colors
source_loc source
Definition: log_msg.h:29
logger & operator=(logger other) SPDLOG_NOEXCEPT
Definition: logger-inl.h:37
#define SPDLOG_TRY
Definition: common.h:102
level::level_enum flush_level() const
Definition: logger-inl.h:135
void disable()
Definition: backtracer-inl.h:40
void err_handler_(const std::string &msg)
Definition: logger-inl.h:227
void set_pattern(std::string pattern, pattern_time_type time_type=pattern_time_type::local)
Definition: logger-inl.h:101
void swap(spdlog::logger &other) SPDLOG_NOEXCEPT
Definition: logger-inl.h:43