Removed logger::clone() from API
This commit is contained in:
		@@ -78,9 +78,3 @@ SPDLOG_INLINE void spdlog::async_logger::backend_flush_()
 | 
			
		||||
    spdlog::logger::flush_();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
SPDLOG_INLINE std::shared_ptr<spdlog::logger> spdlog::async_logger::clone(std::string new_name)
 | 
			
		||||
{
 | 
			
		||||
    auto cloned = std::make_shared<spdlog::async_logger>(*this);
 | 
			
		||||
    cloned->name_ = std::move(new_name);
 | 
			
		||||
    return cloned;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,6 @@ public:
 | 
			
		||||
    async_logger(std::string logger_name, sink_ptr single_sink, std::weak_ptr<details::thread_pool> tp,
 | 
			
		||||
        async_overflow_policy overflow_policy = async_overflow_policy::block);
 | 
			
		||||
 | 
			
		||||
    std::shared_ptr<logger> clone(std::string new_name) override;
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    void sink_it_(const details::log_msg &msg) override;
 | 
			
		||||
 
 | 
			
		||||
@@ -64,7 +64,6 @@ SPDLOG_INLINE void swap(logger &a, logger &b)
 | 
			
		||||
    a.swap(b);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
SPDLOG_INLINE bool logger::should_log(level::level_enum msg_level) const
 | 
			
		||||
{
 | 
			
		||||
    return msg_level >= level_.load(std::memory_order_relaxed);
 | 
			
		||||
@@ -159,14 +158,6 @@ SPDLOG_INLINE void logger::set_error_handler(err_handler handler)
 | 
			
		||||
    custom_err_handler_ = handler;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// create new logger with same sinks and configuration.
 | 
			
		||||
SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
 | 
			
		||||
{
 | 
			
		||||
    auto cloned = std::make_shared<logger>(*this);
 | 
			
		||||
    cloned->name_ = std::move(logger_name);
 | 
			
		||||
    return cloned;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// protected methods
 | 
			
		||||
SPDLOG_INLINE void logger::sink_it_(const details::log_msg &msg)
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -81,7 +81,7 @@ public:
 | 
			
		||||
    void log(source_loc loc, level::level_enum lvl, string_view_t fmt, const Args &... args)
 | 
			
		||||
    {
 | 
			
		||||
        auto level_enabled = should_log(lvl);
 | 
			
		||||
        if(!level_enabled && !tracer_)
 | 
			
		||||
        if (!level_enabled && !tracer_)
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -90,8 +90,14 @@ public:
 | 
			
		||||
            fmt::memory_buffer buf;
 | 
			
		||||
            fmt::format_to(buf, fmt, args...);
 | 
			
		||||
            details::log_msg log_msg(loc, name_, lvl, string_view_t(buf.data(), buf.size()));
 | 
			
		||||
            if (level_enabled) sink_it_(log_msg);
 | 
			
		||||
            if (tracer_) backtrace_add_(log_msg);
 | 
			
		||||
            if (level_enabled)
 | 
			
		||||
            {
 | 
			
		||||
                sink_it_(log_msg);
 | 
			
		||||
            }
 | 
			
		||||
            if (tracer_)
 | 
			
		||||
            {
 | 
			
		||||
                backtrace_add_(log_msg);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        SPDLOG_LOGGER_CATCH()
 | 
			
		||||
    }
 | 
			
		||||
@@ -149,15 +155,21 @@ public:
 | 
			
		||||
    void log(source_loc loc, level::level_enum lvl, const T &msg)
 | 
			
		||||
    {
 | 
			
		||||
        auto level_enabled = should_log(lvl);
 | 
			
		||||
        if(!level_enabled && !tracer_)
 | 
			
		||||
        if (!level_enabled && !tracer_)
 | 
			
		||||
        {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        SPDLOG_TRY
 | 
			
		||||
        {
 | 
			
		||||
            details::log_msg log_msg(loc, name_, lvl, msg);
 | 
			
		||||
            if (level_enabled) sink_it_(log_msg);
 | 
			
		||||
            if (tracer_) backtrace_add_(log_msg);
 | 
			
		||||
            if (level_enabled)
 | 
			
		||||
            {
 | 
			
		||||
                sink_it_(log_msg);
 | 
			
		||||
            }
 | 
			
		||||
            if (tracer_)
 | 
			
		||||
            {
 | 
			
		||||
                backtrace_add_(log_msg);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        SPDLOG_LOGGER_CATCH()
 | 
			
		||||
    }
 | 
			
		||||
@@ -340,8 +352,6 @@ public:
 | 
			
		||||
    // error handler
 | 
			
		||||
    void set_error_handler(err_handler);
 | 
			
		||||
 | 
			
		||||
    // create new logger with same sinks and configuration.
 | 
			
		||||
    virtual std::shared_ptr<logger> clone(std::string logger_name);
 | 
			
		||||
 | 
			
		||||
protected:
 | 
			
		||||
    std::string name_;
 | 
			
		||||
 
 | 
			
		||||
@@ -285,8 +285,7 @@ inline void critical(wstring_view_t fmt, const Args &... args)
 | 
			
		||||
// SPDLOG_LEVEL_OFF
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#define SPDLOG_LOGGER_CALL(logger, level, ...)\
 | 
			
		||||
    logger->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__);                                \
 | 
			
		||||
#define SPDLOG_LOGGER_CALL(logger, level, ...) logger->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__);
 | 
			
		||||
 | 
			
		||||
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
 | 
			
		||||
#define SPDLOG_LOGGER_TRACE(logger, ...) SPDLOG_LOGGER_CALL(logger, spdlog::level::trace, __VA_ARGS__)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user