Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
53ab3492
Unverified
Commit
53ab3492
authored
Nov 03, 2019
by
Gabi Melman
Committed by
GitHub
Nov 03, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1294 from pck/refmacro
Improve log macros
parents
6f6cadf3
eb4a169c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
spdlog.h
include/spdlog/spdlog.h
+2
-2
test_macros.cpp
tests/test_macros.cpp
+8
-0
No files found.
include/spdlog/spdlog.h
View file @
53ab3492
...
@@ -288,8 +288,8 @@ inline void critical(wstring_view_t fmt, const Args &... args)
...
@@ -288,8 +288,8 @@ inline void critical(wstring_view_t fmt, const Args &... args)
#define SPDLOG_LOGGER_CALL(logger, level, ...) \
#define SPDLOG_LOGGER_CALL(logger, level, ...) \
do \
do \
{ \
{ \
if (
logger->should_log(level) || logger->should_backtrace())
\
if (
(logger)->should_log(level) || (logger)->should_backtrace())
\
logger->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__);
\
(logger)->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__);
\
} while (0)
} while (0)
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
#if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE
...
...
tests/test_macros.cpp
View file @
53ab3492
...
@@ -40,6 +40,14 @@ TEST_CASE("disable param evaluation", "[macros]")
...
@@ -40,6 +40,14 @@ TEST_CASE("disable param evaluation", "[macros]")
SPDLOG_TRACE
(
"Test message {}"
,
throw
std
::
runtime_error
(
"Should not be evaluated"
));
SPDLOG_TRACE
(
"Test message {}"
,
throw
std
::
runtime_error
(
"Should not be evaluated"
));
}
}
TEST_CASE
(
"compile with reference to logger"
,
"[macros]"
)
{
auto
logger
=
spdlog
::
create
<
spdlog
::
sinks
::
null_sink_mt
>
(
"refmacro"
);
auto
&
ref
=
*
logger
;
SPDLOG_LOGGER_TRACE
(
&
ref
,
"Test message 1"
);
SPDLOG_LOGGER_DEBUG
(
&
ref
,
"Test message 2"
);
}
// ensure that even if right macro level is on- don't evaluate if the logger's level is not high enough
// ensure that even if right macro level is on- don't evaluate if the logger's level is not high enough
TEST_CASE
(
"disable param evaluation2"
,
"[macros]"
)
TEST_CASE
(
"disable param evaluation2"
,
"[macros]"
)
{
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment