Commit 09cb4500 authored by gabime's avatar gabime

Added copy ctor and assignment to logger

parent 9d3aa5a2
This diff is collapsed.
...@@ -56,8 +56,11 @@ public: ...@@ -56,8 +56,11 @@ public:
virtual ~logger() = default; virtual ~logger() = default;
logger(const logger &) = delete; logger(const logger &other);
logger &operator=(const logger &) = delete; logger(logger &&other);
logger &operator=(logger other);
void swap(spdlog::logger &other);
template<typename... Args> template<typename... Args>
void log(source_loc loc, level::level_enum lvl, const char *fmt, const Args &... args) void log(source_loc loc, level::level_enum lvl, const char *fmt, const Args &... args)
...@@ -328,23 +331,26 @@ public: ...@@ -328,23 +331,26 @@ public:
virtual std::shared_ptr<logger> clone(std::string logger_name); virtual std::shared_ptr<logger> clone(std::string logger_name);
protected: protected:
virtual void sink_it_(details::log_msg &msg); std::string name_;
std::vector<sink_ptr> sinks_;
spdlog::level_t level_{spdlog::logger::default_level()};
spdlog::level_t flush_level_{level::off};
err_handler custom_err_handler_{nullptr};
virtual void sink_it_(details::log_msg &msg);
virtual void flush_(); virtual void flush_();
bool should_flush_(const details::log_msg &msg); bool should_flush_(const details::log_msg &msg);
// default error handler. // default error handler.
// print the error to stderr with the max rate of 1 message/minute. // print the error to stderr with the max rate of 1 message/minute.
void err_handler_(const std::string &msg); void err_handler_(const std::string &msg);
const std::string name_;
std::vector<sink_ptr> sinks_;
spdlog::level_t level_{spdlog::logger::default_level()};
spdlog::level_t flush_level_{level::off};
err_handler custom_err_handler_{nullptr};
}; };
void swap(logger& a, logger& b);
} // namespace spdlog } // namespace spdlog
#ifdef SPDLOG_HEADER_ONLY #ifdef SPDLOG_HEADER_ONLY
#include "logger-inl.h" #include "logger-inl.h"
#endif #endif
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