mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 18:11:33 +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
|
#if __cpp_lib_source_location >= 201907
|
||||||
# include <source_location>
|
# include <source_location>
|
||||||
# define SPDLOG_STD_SOURCE_LOCATION
|
# define SPDLOG_HAVE_STD_SOURCE_LOCATION
|
||||||
#elif __has_include(<experimental/source_location>)
|
#elif __has_include(<experimental/source_location>)
|
||||||
# include <experimental/source_location>
|
# include <experimental/source_location>
|
||||||
# define SPDLOG_EXPERIMENTAL_SOURCE_LOCATION
|
# define SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SPDLOG_USE_STD_FORMAT
|
#ifdef SPDLOG_USE_STD_FORMAT
|
||||||
@ -254,12 +254,12 @@ struct source_loc
|
|||||||
, funcname{funcname_in}
|
, 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())
|
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()};
|
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(
|
static constexpr source_loc current(
|
||||||
const std::experimental::source_location source_location = std::experimental::source_location::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>
|
template<typename... Args>
|
||||||
void trace(loc_with_fmt fmt, Args &&...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)...);
|
default_logger_raw()->log(lvl, fmt, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SPDLOG_EMIT_SOURCE_LOCATION
|
#ifdef SPDLOG_SOURCE_LOCATION
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
inline void trace(loc_with_fmt fmt, Args &&...args)
|
inline void trace(loc_with_fmt fmt, Args &&...args)
|
||||||
{
|
{
|
||||||
@ -306,7 +306,7 @@ inline void critical(string_view_t msg)
|
|||||||
// SPDLOG_LEVEL_OFF
|
// SPDLOG_LEVEL_OFF
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SPDLOG_NO_SOURCE_LOC
|
#ifdef SPDLOG_SOURCE_LOCATION
|
||||||
# define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
# define SPDLOG_LOGGER_CALL(logger, level, ...) \
|
||||||
(logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
|
(logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
|
@ -20,10 +20,8 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Uncomment if source location logging is not needed.
|
// Uncomment if source location logging is needed./
|
||||||
// This will prevent spdlog from using __FILE__, __LINE__ and SPDLOG_FUNCTION
|
// #define SPDLOG_SOURCE_LOCATION
|
||||||
//
|
|
||||||
// #define SPDLOG_NO_SOURCE_LOC
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#define SPDLOG_EMIT_SOURCE_LOCATION
|
#define SPDLOG_SOURCE_LOCATION
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
#include "test_sink.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;
|
using spdlog::details::os::default_eol;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user