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
099137fe
Commit
099137fe
authored
Aug 25, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
backtrace_sink code cleanup
parent
36f25389
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
20 deletions
+17
-20
include/spdlog/logger-inl.h
include/spdlog/logger-inl.h
+8
-10
include/spdlog/logger.h
include/spdlog/logger.h
+1
-1
include/spdlog/sinks/backtrace-sink.h
include/spdlog/sinks/backtrace-sink.h
+7
-7
include/spdlog/sinks/dist_sink.h
include/spdlog/sinks/dist_sink.h
+1
-2
No files found.
include/spdlog/logger-inl.h
View file @
099137fe
...
...
@@ -25,13 +25,12 @@ SPDLOG_INLINE logger::logger(const logger &other)
,
backtrace_sink_
(
other
.
backtrace_sink_
)
{}
SPDLOG_INLINE
logger
::
logger
(
logger
&&
other
)
SPDLOG_NOEXCEPT
:
name_
(
std
::
move
(
other
.
name_
)),
sinks_
(
std
::
move
(
other
.
sinks_
)),
level_
(
other
.
level_
.
load
(
std
::
memory_order_relaxed
)),
flush_level_
(
other
.
flush_level_
.
load
(
std
::
memory_order_relaxed
)),
custom_err_handler_
(
std
::
move
(
other
.
custom_err_handler_
)),
backtrace_sink_
(
std
::
move
(
other
.
backtrace_sink_
))
SPDLOG_INLINE
logger
::
logger
(
logger
&&
other
)
SPDLOG_NOEXCEPT
:
name_
(
std
::
move
(
other
.
name_
)),
sinks_
(
std
::
move
(
other
.
sinks_
)),
level_
(
other
.
level_
.
load
(
std
::
memory_order_relaxed
)),
flush_level_
(
other
.
flush_level_
.
load
(
std
::
memory_order_relaxed
)),
custom_err_handler_
(
std
::
move
(
other
.
custom_err_handler_
)),
backtrace_sink_
(
std
::
move
(
other
.
backtrace_sink_
))
{}
...
...
@@ -88,7 +87,7 @@ SPDLOG_INLINE bool logger::should_log(level::level_enum msg_level) const
SPDLOG_INLINE
void
logger
::
set_level
(
level
::
level_enum
log_level
)
{
if
(
backtrace_sink_
)
if
(
backtrace_sink_
)
{
auto
tracer
=
static_cast
<
sinks
::
backtrace_sink_mt
*>
(
backtrace_sink_
.
get
());
tracer
->
set_filter_level
(
log_level
);
...
...
@@ -139,8 +138,7 @@ SPDLOG_INLINE void logger::enable_backtrace(size_t n_messages)
{
if
(
!
backtrace_sink_
)
{
auto
new_backtrace_sink
=
new
spdlog
::
sinks
::
backtrace_sink_mt
(
level
(),
n_messages
);
new_backtrace_sink
->
set_sinks
(
std
::
move
(
sinks_
));
auto
new_backtrace_sink
=
new
spdlog
::
sinks
::
backtrace_sink_mt
(
std
::
move
(
sinks_
),
level
(),
n_messages
);
backtrace_sink_
.
reset
(
new_backtrace_sink
);
sinks
().
push_back
(
backtrace_sink_
);
assert
(
sinks
().
size
()
==
1
);
...
...
include/spdlog/logger.h
View file @
099137fe
...
...
@@ -351,7 +351,7 @@ protected:
spdlog
::
level_t
flush_level_
{
level
::
off
};
err_handler
custom_err_handler_
{
nullptr
};
sink_ptr
backtrace_sink_
;
//bool backtrace_enabled_{false};
//
bool backtrace_enabled_{false};
virtual
void
sink_it_
(
const
details
::
log_msg
&
msg
);
virtual
void
flush_
();
...
...
include/spdlog/sinks/backtrace-sink.h
View file @
099137fe
...
...
@@ -5,7 +5,6 @@
#include "dist_sink.h"
#include "spdlog/common.h"
#include "spdlog/details/null_mutex.h"
#include "spdlog/details/log_msg_buffer.h"
#include "spdlog/details/circular_q.h"
...
...
@@ -13,9 +12,9 @@
#include <string>
#include <chrono>
// Store log messages in circular buffer
// If it encounters a message with high enough level, it will send all previous message to it child sinks
// Useful for storing debug data in case of error/warning happens
// Store log messages in circular buffer
.
// If it encounters a message with high enough level, it will send all previous message to it child sinks
.
// Useful for storing debug data in case of error/warning happens
.
namespace
spdlog
{
namespace
sinks
{
...
...
@@ -23,10 +22,12 @@ template<typename Mutex>
class
backtrace_sink
:
public
dist_sink
<
Mutex
>
{
public:
explicit
backtrace_sink
(
spdlog
::
level
::
level_enum
filter_level
,
size_t
n_messages
)
backtrace_sink
(
std
::
vector
<
std
::
shared_ptr
<
sink
>>
&&
child_sinks
,
spdlog
::
level
::
level_enum
filter_level
,
size_t
n_messages
)
:
filter_level_
{
filter_level
}
,
traceback_msgs_
{
n_messages
}
{}
{
dist_sink
<
Mutex
>::
set_sinks
(
std
::
move
(
child_sinks
));
}
void
set_filter_level
(
spdlog
::
level
::
level_enum
filter_level
)
{
...
...
@@ -83,7 +84,6 @@ protected:
};
using
backtrace_sink_mt
=
backtrace_sink
<
std
::
mutex
>
;
using
backtrace_sink_st
=
backtrace_sink
<
details
::
null_mutex
>
;
}
// namespace sinks
}
// namespace spdlog
include/spdlog/sinks/dist_sink.h
View file @
099137fe
...
...
@@ -45,12 +45,11 @@ public:
sinks_
=
std
::
move
(
sinks
);
}
std
::
vector
<
std
::
shared_ptr
<
sink
>>
&
sinks
()
std
::
vector
<
std
::
shared_ptr
<
sink
>>
&
sinks
()
{
return
sinks_
;
}
protected:
void
sink_it_
(
const
details
::
log_msg
&
msg
)
override
{
...
...
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