Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
spdlog
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
spdlog
Commits
6ba5ab6d
Unverified
Commit
6ba5ab6d
authored
May 20, 2021
by
Gabi Melman
Committed by
GitHub
May 20, 2021
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1948 from stevenlunt/v1.x
add macros for overriding the individual level names
parents
af0d805b
1bee3218
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
16 deletions
+94
-16
CMakeLists.txt
CMakeLists.txt
+19
-0
include/spdlog/common-inl.h
include/spdlog/common-inl.h
+3
-5
include/spdlog/common.h
include/spdlog/common.h
+29
-2
include/spdlog/tweakme.h
include/spdlog/tweakme.h
+43
-1
tests/test_misc.cpp
tests/test_misc.cpp
+0
-8
No files found.
CMakeLists.txt
View file @
6ba5ab6d
...
...
@@ -235,6 +235,25 @@ if(SPDLOG_NO_EXCEPTIONS AND NOT MSVC)
target_compile_options
(
spdlog PRIVATE -fno-exceptions
)
endif
()
# ---------------------------------------------------------------------------------------
# Allow override of level names
# ---------------------------------------------------------------------------------------
set
(
SPDLOG_LEVEL_NAME_TRACE
"trace"
CACHE STRING
"custom level name"
)
set
(
SPDLOG_LEVEL_NAME_DEBUG
"debug"
CACHE STRING
"custom level name"
)
set
(
SPDLOG_LEVEL_NAME_INFO
"info"
CACHE STRING
"custom level name"
)
set
(
SPDLOG_LEVEL_NAME_WARNING
"warning"
CACHE STRING
"custom level name"
)
set
(
SPDLOG_LEVEL_NAME_ERROR
"error"
CACHE STRING
"custom level name"
)
set
(
SPDLOG_LEVEL_NAME_CRITICAL
"critical"
CACHE STRING
"custom level name"
)
set
(
SPDLOG_LEVEL_NAME_OFF
"off"
CACHE STRING
"custom level name"
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_LEVEL_NAME_TRACE=\"
${
SPDLOG_LEVEL_NAME_TRACE
}
\"
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_LEVEL_NAME_DEBUG=\"
${
SPDLOG_LEVEL_NAME_DEBUG
}
\"
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_LEVEL_NAME_INFO=\"
${
SPDLOG_LEVEL_NAME_INFO
}
\"
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_LEVEL_NAME_WARNING=\"
${
SPDLOG_LEVEL_NAME_WARNING
}
\"
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_LEVEL_NAME_ERROR=\"
${
SPDLOG_LEVEL_NAME_ERROR
}
\"
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_LEVEL_NAME_CRITICAL=\"
${
SPDLOG_LEVEL_NAME_CRITICAL
}
\"
)
target_compile_definitions
(
spdlog PUBLIC SPDLOG_LEVEL_NAME_OFF=\"
${
SPDLOG_LEVEL_NAME_OFF
}
\"
)
# ---------------------------------------------------------------------------------------
# Build binaries
# ---------------------------------------------------------------------------------------
...
...
include/spdlog/common-inl.h
View file @
6ba5ab6d
...
...
@@ -13,6 +13,9 @@
namespace
spdlog
{
namespace
level
{
#if __cplusplus >= 201703L
constexpr
#endif
static
string_view_t
level_string_views
[]
SPDLOG_LEVEL_NAMES
;
static
const
char
*
short_level_names
[]
SPDLOG_SHORT_LEVEL_NAMES
;
...
...
@@ -22,11 +25,6 @@ SPDLOG_INLINE const string_view_t &to_string_view(spdlog::level::level_enum l) S
return
level_string_views
[
l
];
}
SPDLOG_INLINE
void
set_string_view
(
spdlog
::
level
::
level_enum
l
,
const
string_view_t
&
s
)
SPDLOG_NOEXCEPT
{
level_string_views
[
l
]
=
s
;
}
SPDLOG_INLINE
const
char
*
to_short_c_str
(
spdlog
::
level
::
level_enum
l
)
SPDLOG_NOEXCEPT
{
return
short_level_names
[
l
];
...
...
include/spdlog/common.h
View file @
6ba5ab6d
...
...
@@ -152,10 +152,38 @@ enum level_enum
n_levels
};
#if !defined(SPDLOG_LEVEL_NAME_TRACE)
#define SPDLOG_LEVEL_NAME_TRACE "trace"
#endif
#if !defined(SPDLOG_LEVEL_NAME_DEBUG)
#define SPDLOG_LEVEL_NAME_DEBUG "debug"
#endif
#if !defined(SPDLOG_LEVEL_NAME_INFO)
#define SPDLOG_LEVEL_NAME_INFO "info"
#endif
#if !defined(SPDLOG_LEVEL_NAME_WARNING)
#define SPDLOG_LEVEL_NAME_WARNING "warning"
#endif
#if !defined(SPDLOG_LEVEL_NAME_ERROR)
#define SPDLOG_LEVEL_NAME_ERROR "error"
#endif
#if !defined(SPDLOG_LEVEL_NAME_CRITICAL)
#define SPDLOG_LEVEL_NAME_CRITICAL "critical"
#endif
#if !defined(SPDLOG_LEVEL_NAME_OFF)
#define SPDLOG_LEVEL_NAME_OFF "off"
#endif
#if !defined(SPDLOG_LEVEL_NAMES)
#define SPDLOG_LEVEL_NAMES \
{ \
"trace", "debug", "info", "warning", "error", "critical", "off"
\
SPDLOG_LEVEL_NAME_TRACE, SPDLOG_LEVEL_NAME_DEBUG, SPDLOG_LEVEL_NAME_INFO, SPDLOG_LEVEL_NAME_WARNING, SPDLOG_LEVEL_NAME_ERROR, SPDLOG_LEVEL_NAME_CRITICAL, SPDLOG_LEVEL_NAME_OFF
\
}
#endif
...
...
@@ -168,7 +196,6 @@ enum level_enum
#endif
SPDLOG_API
const
string_view_t
&
to_string_view
(
spdlog
::
level
::
level_enum
l
)
SPDLOG_NOEXCEPT
;
SPDLOG_API
void
set_string_view
(
spdlog
::
level
::
level_enum
l
,
const
string_view_t
&
s
)
SPDLOG_NOEXCEPT
;
SPDLOG_API
const
char
*
to_short_c_str
(
spdlog
::
level
::
level_enum
l
)
SPDLOG_NOEXCEPT
;
SPDLOG_API
spdlog
::
level
::
level_enum
from_str
(
const
std
::
string
&
name
)
SPDLOG_NOEXCEPT
;
...
...
include/spdlog/tweakme.h
View file @
6ba5ab6d
...
...
@@ -87,12 +87,54 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize level names (e.g. "M
T
TRACE")
// Uncomment to customize level names (e.g. "M
Y
TRACE")
//
// #define SPDLOG_LEVEL_NAMES { "MY TRACE", "MY DEBUG", "MY INFO", "MY WARNING",
// "MY ERROR", "MY CRITICAL", "OFF" }
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize the trace level name
//
// #define SPDLOG_LEVEL_NAME_TRACE "MY TRACE"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize the debug level name
//
// #define SPDLOG_LEVEL_NAME_DEBUG "MY DEBUG"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize the info level name
//
// #define SPDLOG_LEVEL_NAME_INFO "MY INFO"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize the warning level name
//
// #define SPDLOG_LEVEL_NAME_WARNING "MY WARNING"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize the error level name
//
// #define SPDLOG_LEVEL_NAME_ERROR "MY ERROR"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize the critical level name
//
// #define SPDLOG_LEVEL_NAME_CRITICAL "MY CRITICAL"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize the off level name
//
// #define SPDLOG_LEVEL_NAME_OFF "MY OFF"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to customize short level names (e.g. "MT")
// These can be longer than one character.
...
...
tests/test_misc.cpp
View file @
6ba5ab6d
...
...
@@ -55,14 +55,6 @@ TEST_CASE("level_to_string_view", "[convert_to_string_view")
REQUIRE
(
spdlog
::
level
::
to_string_view
(
spdlog
::
level
::
off
)
==
"off"
);
}
TEST_CASE
(
"set_level_to_string_view"
,
"[set_string_view"
)
{
spdlog
::
level
::
set_string_view
(
spdlog
::
level
::
info
,
"INF"
);
REQUIRE
(
spdlog
::
level
::
to_string_view
(
spdlog
::
level
::
info
)
==
"INF"
);
spdlog
::
level
::
set_string_view
(
spdlog
::
level
::
info
,
"info"
);
// set it back
REQUIRE
(
spdlog
::
level
::
to_string_view
(
spdlog
::
level
::
info
)
==
"info"
);
}
TEST_CASE
(
"to_short_c_str"
,
"[convert_to_short_c_str]"
)
{
REQUIRE
(
std
::
string
(
spdlog
::
level
::
to_short_c_str
(
spdlog
::
level
::
trace
))
==
"T"
);
...
...
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