|
|
@ -21,8 +21,8 @@
|
|
|
|
#define SPDLITE_LEVEL_CRITICAL 5
|
|
|
|
#define SPDLITE_LEVEL_CRITICAL 5
|
|
|
|
#define SPDLITE_LEVEL_OFF 6
|
|
|
|
#define SPDLITE_LEVEL_OFF 6
|
|
|
|
|
|
|
|
|
|
|
|
#define SPDLITE_LOGGER_CALL(logger, level, ...) \
|
|
|
|
#define SPDLITE_LOGGER_CALL(logger, level, ...) \
|
|
|
|
if (logger.should_log(level)) \
|
|
|
|
if (logger.should_log(level)) \
|
|
|
|
logger.log(level, __VA_ARGS__)
|
|
|
|
logger.log(level, __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
|
|
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_TRACE
|
|
|
|
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_TRACE
|
|
|
@ -73,169 +73,169 @@
|
|
|
|
#define SPDLITE_CRITICAL(...) (void)0
|
|
|
|
#define SPDLITE_CRITICAL(...) (void)0
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace spdlog {
|
|
|
|
namespace spdlog {
|
|
|
|
class logger;
|
|
|
|
class logger;
|
|
|
|
|
|
|
|
|
|
|
|
namespace lite {
|
|
|
|
namespace lite {
|
|
|
|
enum class level{
|
|
|
|
enum class level
|
|
|
|
trace = SPDLITE_LEVEL_TRACE,
|
|
|
|
{
|
|
|
|
debug =SPDLITE_LEVEL_DEBUG,
|
|
|
|
trace = SPDLITE_LEVEL_TRACE,
|
|
|
|
info = SPDLITE_LEVEL_INFO,
|
|
|
|
debug = SPDLITE_LEVEL_DEBUG,
|
|
|
|
warn = SPDLITE_LEVEL_WARN,
|
|
|
|
info = SPDLITE_LEVEL_INFO,
|
|
|
|
err = SPDLITE_LEVEL_ERROR,
|
|
|
|
warn = SPDLITE_LEVEL_WARN,
|
|
|
|
critical = SPDLITE_LEVEL_CRITICAL,
|
|
|
|
err = SPDLITE_LEVEL_ERROR,
|
|
|
|
off = SPDLITE_LEVEL_OFF
|
|
|
|
critical = SPDLITE_LEVEL_CRITICAL,
|
|
|
|
};
|
|
|
|
off = SPDLITE_LEVEL_OFF
|
|
|
|
|
|
|
|
};
|
|
|
|
struct src_loc {
|
|
|
|
|
|
|
|
const char *filename;
|
|
|
|
struct src_loc
|
|
|
|
int line;
|
|
|
|
{
|
|
|
|
const char* funcname;
|
|
|
|
const char *filename;
|
|
|
|
};
|
|
|
|
int line;
|
|
|
|
|
|
|
|
const char *funcname;
|
|
|
|
class logger {
|
|
|
|
};
|
|
|
|
public:
|
|
|
|
|
|
|
|
logger() = default;
|
|
|
|
class logger
|
|
|
|
|
|
|
|
{
|
|
|
|
logger(std::shared_ptr<spdlog::logger> impl);
|
|
|
|
public:
|
|
|
|
logger(const logger&) = default;
|
|
|
|
logger() = default;
|
|
|
|
logger(logger&&) = default;
|
|
|
|
|
|
|
|
logger& operator=(const logger&) = default;
|
|
|
|
logger(std::shared_ptr<spdlog::logger> impl);
|
|
|
|
|
|
|
|
logger(const logger &) = default;
|
|
|
|
~logger() = default;
|
|
|
|
logger(logger &&) = default;
|
|
|
|
|
|
|
|
logger &operator=(const logger &) = default;
|
|
|
|
bool should_log(spdlog::lite::level lvl) const noexcept;
|
|
|
|
|
|
|
|
|
|
|
|
~logger() = default;
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void log(spdlog::lite::level lvl, const char *fmt, const Args &... args) {
|
|
|
|
bool should_log(spdlog::lite::level lvl) const noexcept;
|
|
|
|
if (!should_log(lvl)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
template<typename... Args>
|
|
|
|
}
|
|
|
|
void log(spdlog::lite::level lvl, const char *fmt, const Args &... args)
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
|
{
|
|
|
|
fmt::format_to(formatted_buf, fmt, args...);
|
|
|
|
if (!should_log(lvl))
|
|
|
|
log_formatted_(lvl, formatted_buf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void log(const spdlog::lite::src_loc& src, spdlog::lite::level lvl, const char *fmt, const Args &... args) {
|
|
|
|
|
|
|
|
if (!should_log(lvl)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
|
|
|
|
|
fmt::format_to(formatted_buf, fmt, args...);
|
|
|
|
|
|
|
|
log_formatted_src(src, lvl, formatted_buf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::trace, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void trace(const char* source_file, int source_line, const char* source_func, const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
spdlog::lite::src_loc src{source_file, source_line, source_func};
|
|
|
|
|
|
|
|
log(src, spdlog::lite::level::trace, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void debug(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::debug, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void info(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::info, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void warn(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::warn, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void error(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::err, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void critical(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::critical, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string name() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// level
|
|
|
|
|
|
|
|
void set_level(lite::level level);
|
|
|
|
|
|
|
|
lite::level get_level() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// flush
|
|
|
|
|
|
|
|
void flush();
|
|
|
|
|
|
|
|
void flush_on(spdlog::lite::level log_level);
|
|
|
|
|
|
|
|
spdlog::lite::level flush_level() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pattern
|
|
|
|
|
|
|
|
void set_pattern(std::string pattern);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
std::shared_ptr<spdlog::logger> impl_;
|
|
|
|
|
|
|
|
void log_formatted_(spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
|
|
|
|
|
|
|
|
void log_formatted_src(const spdlog::lite::src_loc& src, spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
spdlog::lite::logger& default_logger();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
default_logger().trace(fmt, args...);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template<typename... Args>
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
|
void debug(const char *fmt, const Args &... args)
|
|
|
|
fmt::format_to(formatted_buf, fmt, args...);
|
|
|
|
{
|
|
|
|
log_formatted_(lvl, formatted_buf);
|
|
|
|
default_logger().debug(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void log(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const char *fmt, const Args &... args)
|
|
|
|
void info(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!should_log(lvl))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
default_logger().info(fmt, args...);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
|
template<typename... Args>
|
|
|
|
fmt::format_to(formatted_buf, fmt, args...);
|
|
|
|
void warn(const char *fmt, const Args &... args)
|
|
|
|
log_formatted_src(src, lvl, formatted_buf);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
default_logger().warn(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
template<typename... Args>
|
|
|
|
{
|
|
|
|
void error(const char *fmt, const Args &... args)
|
|
|
|
log(spdlog::lite::level::trace, fmt, args...);
|
|
|
|
{
|
|
|
|
}
|
|
|
|
default_logger().error(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void trace(const char *source_file, int source_line, const char *source_func, const char *fmt, const Args &... args)
|
|
|
|
template<typename... Args>
|
|
|
|
{
|
|
|
|
void critical(const char *fmt, const Args &... args)
|
|
|
|
spdlog::lite::src_loc src{source_file, source_line, source_func};
|
|
|
|
{
|
|
|
|
log(src, spdlog::lite::level::trace, fmt, args...);
|
|
|
|
default_logger().critical(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void debug(const char *fmt, const Args &... args)
|
|
|
|
} // namespace lite
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::debug, fmt, args...);
|
|
|
|
// factory to create lite logger
|
|
|
|
}
|
|
|
|
// implement it in a dedicated compilation unit for fast compiles
|
|
|
|
|
|
|
|
spdlog::lite::logger create_lite(void* ctx = nullptr);
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void info(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::info, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void warn(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::warn, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void error(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::err, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void critical(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
log(spdlog::lite::level::critical, fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string name() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// level
|
|
|
|
|
|
|
|
void set_level(lite::level level);
|
|
|
|
|
|
|
|
lite::level get_level() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// flush
|
|
|
|
|
|
|
|
void flush();
|
|
|
|
|
|
|
|
void flush_on(spdlog::lite::level log_level);
|
|
|
|
|
|
|
|
spdlog::lite::level flush_level() const;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// pattern
|
|
|
|
|
|
|
|
void set_pattern(std::string pattern);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
std::shared_ptr<spdlog::logger> impl_;
|
|
|
|
|
|
|
|
void log_formatted_(spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
|
|
|
|
|
|
|
|
void log_formatted_src(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
spdlog::lite::logger &default_logger();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
default_logger().trace(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void debug(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
default_logger().debug(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void info(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
default_logger().info(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void warn(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
default_logger().warn(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void error(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
default_logger().error(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
|
|
|
|
void critical(const char *fmt, const Args &... args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
default_logger().critical(fmt, args...);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lite
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// factory to create lite logger
|
|
|
|
|
|
|
|
// implement it in a dedicated compilation unit for fast compiles
|
|
|
|
|
|
|
|
spdlog::lite::logger create_lite(void *ctx = nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace spdlog
|
|
|
|
} // namespace spdlog
|