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
709948ff
Commit
709948ff
authored
Oct 12, 2017
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue #527
parent
96886899
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
21 additions
and
6 deletions
+21
-6
include/spdlog/details/async_logger_impl.h
include/spdlog/details/async_logger_impl.h
+1
-1
include/spdlog/details/logger_impl.h
include/spdlog/details/logger_impl.h
+6
-1
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+9
-2
include/spdlog/logger.h
include/spdlog/logger.h
+3
-0
include/spdlog/tweakme.h
include/spdlog/tweakme.h
+2
-2
No files found.
include/spdlog/details/async_logger_impl.h
View file @
709948ff
...
@@ -88,7 +88,7 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
...
@@ -88,7 +88,7 @@ inline void spdlog::async_logger::_sink_it(details::log_msg& msg)
try
try
{
{
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
msg
.
msg_id
=
_msg_counter
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
_incr_msg_counter
(
msg
);
#endif
#endif
_async_log_helper
->
log
(
msg
);
_async_log_helper
->
log
(
msg
);
if
(
_should_flush_on
(
msg
))
if
(
_should_flush_on
(
msg
))
...
...
include/spdlog/details/logger_impl.h
View file @
709948ff
...
@@ -512,7 +512,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
...
@@ -512,7 +512,7 @@ inline bool spdlog::logger::should_log(spdlog::level::level_enum msg_level) cons
inline
void
spdlog
::
logger
::
_sink_it
(
details
::
log_msg
&
msg
)
inline
void
spdlog
::
logger
::
_sink_it
(
details
::
log_msg
&
msg
)
{
{
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
msg
.
msg_id
=
_msg_counter
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
_incr_msg_counter
(
msg
);
#endif
#endif
_formatter
->
format
(
msg
);
_formatter
->
format
(
msg
);
for
(
auto
&
sink
:
_sinks
)
for
(
auto
&
sink
:
_sinks
)
...
@@ -562,6 +562,11 @@ inline bool spdlog::logger::_should_flush_on(const details::log_msg &msg)
...
@@ -562,6 +562,11 @@ inline bool spdlog::logger::_should_flush_on(const details::log_msg &msg)
return
(
msg
.
level
>=
flush_level
)
&&
(
msg
.
level
!=
level
::
off
);
return
(
msg
.
level
>=
flush_level
)
&&
(
msg
.
level
!=
level
::
off
);
}
}
inline
void
spdlog
::
logger
::
_incr_msg_counter
(
details
::
log_msg
&
msg
)
{
msg
.
msg_id
=
_msg_counter
.
fetch_add
(
1
,
std
::
memory_order_relaxed
);
}
inline
const
std
::
vector
<
spdlog
::
sink_ptr
>&
spdlog
::
logger
::
sinks
()
const
inline
const
std
::
vector
<
spdlog
::
sink_ptr
>&
spdlog
::
logger
::
sinks
()
const
{
{
return
_sinks
;
return
_sinks
;
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
709948ff
...
@@ -384,6 +384,14 @@ class pid_formatter SPDLOG_FINAL:public flag_formatter
...
@@ -384,6 +384,14 @@ class pid_formatter SPDLOG_FINAL:public flag_formatter
}
}
};
};
// message counter formatter
class
i_formatter
SPDLOG_FINAL
:
public
flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
tm_time
)
override
{
msg
.
formatted
<<
fmt
::
pad
(
msg
.
msg_id
,
6
,
'0'
);
}
};
class
v_formatter
SPDLOG_FINAL
:
public
flag_formatter
class
v_formatter
SPDLOG_FINAL
:
public
flag_formatter
{
{
...
@@ -641,11 +649,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
...
@@ -641,11 +649,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
pid_formatter
()));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
pid_formatter
()));
break
;
break
;
#if defined(SPDLOG_ENABLE_MESSAGE_COUNTER)
case
(
'i'
):
case
(
'i'
):
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
i_formatter
()));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
i_formatter
()));
break
;
break
;
#endif
default:
//Unknown flag appears as is
default:
//Unknown flag appears as is
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
ch_formatter
(
'%'
)));
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
ch_formatter
(
'%'
)));
...
...
include/spdlog/logger.h
View file @
709948ff
...
@@ -118,6 +118,9 @@ protected:
...
@@ -118,6 +118,9 @@ protected:
// return true if the given message level should trigger a flush
// return true if the given message level should trigger a flush
bool
_should_flush_on
(
const
details
::
log_msg
&
);
bool
_should_flush_on
(
const
details
::
log_msg
&
);
// increment the message count (only if defined(SPDLOG_ENABLE_MESSAGE_COUNTER))
void
_incr_msg_counter
(
details
::
log_msg
&
msg
);
const
std
::
string
_name
;
const
std
::
string
_name
;
std
::
vector
<
sink_ptr
>
_sinks
;
std
::
vector
<
sink_ptr
>
_sinks
;
formatter_ptr
_formatter
;
formatter_ptr
_formatter
;
...
...
include/spdlog/tweakme.h
View file @
709948ff
...
@@ -135,8 +135,8 @@
...
@@ -135,8 +135,8 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable message counting feature.
Adds %i logger pattern that
// Uncomment to enable message counting feature.
//
prints
log message sequence id.
//
Use the %i in the logger pattern to display
log message sequence id.
//
//
// #define SPDLOG_ENABLE_MESSAGE_COUNTER
// #define SPDLOG_ENABLE_MESSAGE_COUNTER
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
...
...
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