mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-24 17:41:34 +08:00
check SPDLOG_SOURCE_LOCATION in macros and in runtime
This commit is contained in:
parent
ea1c829764
commit
7c0afada60
@ -24,10 +24,10 @@
|
||||
|
||||
#if __cpp_lib_source_location >= 201907
|
||||
# include <source_location>
|
||||
# define SPDLOG_STD_SOURCE_LOCATION
|
||||
# define SPDLOG_HAVE_STD_SOURCE_LOCATION
|
||||
#elif __has_include(<experimental/source_location>)
|
||||
# include <experimental/source_location>
|
||||
# define SPDLOG_EXPERIMENTAL_SOURCE_LOCATION
|
||||
# define SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION
|
||||
#endif
|
||||
|
||||
#ifdef SPDLOG_USE_STD_FORMAT
|
||||
@ -254,12 +254,12 @@ struct source_loc
|
||||
, funcname{funcname_in}
|
||||
{}
|
||||
|
||||
#ifdef SPDLOG_STD_SOURCE_LOCATION
|
||||
#ifdef SPDLOG_HAVE_STD_SOURCE_LOCATION
|
||||
static constexpr source_loc current(const std::source_location source_location = std::source_location::current())
|
||||
{
|
||||
return source_loc{source_location.file_name(), source_location.line(), source_location.function_name()};
|
||||
}
|
||||
#elif defined(SPDLOG_EXPERIMENTAL_SOURCE_LOCATION)
|
||||
#elif defined(SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION)
|
||||
static constexpr source_loc current(
|
||||
const std::experimental::source_location source_location = std::experimental::source_location::current())
|
||||
{
|
||||
|
@ -129,7 +129,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SPDLOG_EMIT_SOURCE_LOCATION
|
||||
#ifdef SPDLOG_SOURCE_LOCATION
|
||||
template<typename... Args>
|
||||
void trace(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
|
@ -155,7 +155,7 @@ inline void log(log_level lvl, S fmt, Args &&...args)
|
||||
default_logger_raw()->log(lvl, fmt, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
#ifdef SPDLOG_EMIT_SOURCE_LOCATION
|
||||
#ifdef SPDLOG_SOURCE_LOCATION
|
||||
template<typename... Args>
|
||||
inline void trace(loc_with_fmt fmt, Args &&...args)
|
||||
{
|
||||
@ -306,7 +306,7 @@ inline void critical(string_view_t msg)
|
||||
// SPDLOG_LEVEL_OFF
|
||||
//
|
||||
|
||||
#ifndef SPDLOG_NO_SOURCE_LOC
|
||||
#ifdef SPDLOG_SOURCE_LOCATION
|
||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
||||
(logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
|
||||
#else
|
||||
|
@ -20,10 +20,8 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Uncomment if source location logging is not needed.
|
||||
// This will prevent spdlog from using __FILE__, __LINE__ and SPDLOG_FUNCTION
|
||||
//
|
||||
// #define SPDLOG_NO_SOURCE_LOC
|
||||
// Uncomment if source location logging is needed./
|
||||
// #define SPDLOG_SOURCE_LOCATION
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,8 +1,8 @@
|
||||
#define SPDLOG_EMIT_SOURCE_LOCATION
|
||||
#define SPDLOG_SOURCE_LOCATION
|
||||
#include "includes.h"
|
||||
#include "test_sink.h"
|
||||
|
||||
#if defined(SPDLOG_STD_SOURCE_LOCATION) || defined(SPDLOG_EXPERIMENTAL_SOURCE_LOCATION)
|
||||
#if defined(SPDLOG_HAVE_STD_SOURCE_LOCATION) || defined(SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION)
|
||||
|
||||
using spdlog::details::os::default_eol;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user