|
|
@ -73,44 +73,47 @@
|
|
|
|
#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,
|
|
|
|
trace = SPDLITE_LEVEL_TRACE,
|
|
|
|
debug =SPDLITE_LEVEL_DEBUG,
|
|
|
|
debug = SPDLITE_LEVEL_DEBUG,
|
|
|
|
info = SPDLITE_LEVEL_INFO,
|
|
|
|
info = SPDLITE_LEVEL_INFO,
|
|
|
|
warn = SPDLITE_LEVEL_WARN,
|
|
|
|
warn = SPDLITE_LEVEL_WARN,
|
|
|
|
err = SPDLITE_LEVEL_ERROR,
|
|
|
|
err = SPDLITE_LEVEL_ERROR,
|
|
|
|
critical = SPDLITE_LEVEL_CRITICAL,
|
|
|
|
critical = SPDLITE_LEVEL_CRITICAL,
|
|
|
|
off = SPDLITE_LEVEL_OFF
|
|
|
|
off = SPDLITE_LEVEL_OFF
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct src_loc {
|
|
|
|
struct src_loc
|
|
|
|
|
|
|
|
{
|
|
|
|
const char *filename;
|
|
|
|
const char *filename;
|
|
|
|
int line;
|
|
|
|
int line;
|
|
|
|
const char* funcname;
|
|
|
|
const char *funcname;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class logger {
|
|
|
|
class logger
|
|
|
|
public:
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
logger() = default;
|
|
|
|
logger() = default;
|
|
|
|
|
|
|
|
|
|
|
|
logger(std::shared_ptr<spdlog::logger> impl);
|
|
|
|
logger(std::shared_ptr<spdlog::logger> impl);
|
|
|
|
logger(const logger&) = default;
|
|
|
|
logger(const logger &) = default;
|
|
|
|
logger(logger&&) = default;
|
|
|
|
logger(logger &&) = default;
|
|
|
|
logger& operator=(const logger&) = default;
|
|
|
|
logger &operator=(const logger &) = default;
|
|
|
|
|
|
|
|
|
|
|
|
~logger() = default;
|
|
|
|
~logger() = default;
|
|
|
|
|
|
|
|
|
|
|
|
bool should_log(spdlog::lite::level lvl) const noexcept;
|
|
|
|
bool should_log(spdlog::lite::level lvl) const noexcept;
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void log(spdlog::lite::level lvl, const char *fmt, const Args &... args) {
|
|
|
|
void log(spdlog::lite::level lvl, const char *fmt, const Args &... args)
|
|
|
|
if (!should_log(lvl)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!should_log(lvl))
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
@ -118,10 +121,11 @@ namespace spdlog {
|
|
|
|
log_formatted_(lvl, formatted_buf);
|
|
|
|
log_formatted_(lvl, formatted_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 log(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const char *fmt, const Args &... args)
|
|
|
|
if (!should_log(lvl)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!should_log(lvl))
|
|
|
|
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
|
fmt::memory_buffer formatted_buf;
|
|
|
@ -129,7 +133,6 @@ namespace spdlog {
|
|
|
|
log_formatted_src(src, lvl, formatted_buf);
|
|
|
|
log_formatted_src(src, lvl, formatted_buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -137,7 +140,7 @@ namespace spdlog {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void trace(const char* source_file, int source_line, const char* source_func, const char *fmt, const Args &... 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};
|
|
|
|
spdlog::lite::src_loc src{source_file, source_line, source_func};
|
|
|
|
log(src, spdlog::lite::level::trace, fmt, args...);
|
|
|
|
log(src, spdlog::lite::level::trace, fmt, args...);
|
|
|
@ -187,55 +190,52 @@ namespace spdlog {
|
|
|
|
// pattern
|
|
|
|
// pattern
|
|
|
|
void set_pattern(std::string pattern);
|
|
|
|
void set_pattern(std::string pattern);
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
std::shared_ptr<spdlog::logger> impl_;
|
|
|
|
std::shared_ptr<spdlog::logger> impl_;
|
|
|
|
void log_formatted_(spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
|
|
|
|
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);
|
|
|
|
void log_formatted_src(const spdlog::lite::src_loc &src, spdlog::lite::level lvl, const fmt::memory_buffer &formatted);
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
spdlog::lite::logger &default_logger();
|
|
|
|
spdlog::lite::logger& default_logger();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
void trace(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
default_logger().trace(fmt, args...);
|
|
|
|
default_logger().trace(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void debug(const char *fmt, const Args &... args)
|
|
|
|
void debug(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
default_logger().debug(fmt, args...);
|
|
|
|
default_logger().debug(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void info(const char *fmt, const Args &... args)
|
|
|
|
void info(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
default_logger().info(fmt, args...);
|
|
|
|
default_logger().info(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void warn(const char *fmt, const Args &... args)
|
|
|
|
void warn(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
default_logger().warn(fmt, args...);
|
|
|
|
default_logger().warn(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void error(const char *fmt, const Args &... args)
|
|
|
|
void error(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
default_logger().error(fmt, args...);
|
|
|
|
default_logger().error(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template<typename... Args>
|
|
|
|
template<typename... Args>
|
|
|
|
void critical(const char *fmt, const Args &... args)
|
|
|
|
void critical(const char *fmt, const Args &... args)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
default_logger().critical(fmt, args...);
|
|
|
|
default_logger().critical(fmt, args...);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lite
|
|
|
|
} // namespace lite
|
|
|
|
|
|
|
|
|
|
|
|
// factory to create lite logger
|
|
|
|
// factory to create lite logger
|
|
|
|
// implement it in a dedicated compilation unit for fast compiles
|
|
|
|
// implement it in a dedicated compilation unit for fast compiles
|
|
|
|
spdlog::lite::logger create_lite(void* ctx = nullptr);
|
|
|
|
spdlog::lite::logger create_lite(void *ctx = nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace spdlog
|
|
|
|
} // namespace spdlog
|