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
fcc809f4
Commit
fcc809f4
authored
Oct 18, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored logger
parent
f3369677
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
45 deletions
+28
-45
include/spdlog/details/backtracer-inl.h
include/spdlog/details/backtracer-inl.h
+0
-4
include/spdlog/details/backtracer.h
include/spdlog/details/backtracer.h
+0
-1
include/spdlog/logger-inl.h
include/spdlog/logger-inl.h
+13
-1
include/spdlog/logger.h
include/spdlog/logger.h
+15
-39
No files found.
include/spdlog/details/backtracer-inl.h
View file @
fcc809f4
...
...
@@ -48,10 +48,6 @@ SPDLOG_INLINE bool backtracer::enabled() const
return
enabled_
.
load
(
std
::
memory_order_relaxed
);
}
SPDLOG_INLINE
backtracer
::
operator
bool
()
const
{
return
enabled
();
}
SPDLOG_INLINE
void
backtracer
::
push_back
(
const
log_msg
&
msg
)
{
...
...
include/spdlog/details/backtracer.h
View file @
fcc809f4
...
...
@@ -31,7 +31,6 @@ public:
void
enable
(
size_t
size
);
void
disable
();
bool
enabled
()
const
;
explicit
operator
bool
()
const
;
void
push_back
(
const
log_msg
&
msg
);
// pop all items in the q and apply the given fun on each of them.
...
...
include/spdlog/logger-inl.h
View file @
fcc809f4
...
...
@@ -172,6 +172,18 @@ SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
}
// protected methods
SPDLOG_INLINE
void
logger
::
log_it_
(
const
details
::
log_msg
&
log_msg
)
{
if
(
should_log
(
log_msg
.
level
))
{
sink_it_
(
log_msg
);
}
if
(
tracer_
.
enabled
())
{
tracer_
.
push_back
(
log_msg
);
}
}
SPDLOG_INLINE
void
logger
::
sink_it_
(
const
details
::
log_msg
&
msg
)
{
for
(
auto
&
sink
:
sinks_
)
...
...
@@ -207,7 +219,7 @@ SPDLOG_INLINE void logger::flush_()
SPDLOG_INLINE
void
logger
::
dump_backtrace_
()
{
using
details
::
log_msg
;
if
(
tracer_
)
if
(
tracer_
.
enabled
()
)
{
sink_it_
(
log_msg
{
name
(),
level
::
info
,
"****************** Backtrace Start ******************"
});
tracer_
.
foreach_pop
([
this
](
const
log_msg
&
msg
)
{
this
->
sink_it_
(
msg
);
});
...
...
include/spdlog/logger.h
View file @
fcc809f4
...
...
@@ -73,11 +73,11 @@ public:
void
swap
(
spdlog
::
logger
&
other
)
SPDLOG_NOEXCEPT
;
template
<
typename
...
Args
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
string_view_t
fmt
,
const
Args
&
...
args
)
{
auto
level_enabled
=
should_log
(
lvl
);
if
(
!
level_enabled
&&
!
tracer_
)
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
())
{
return
;
}
...
...
@@ -86,14 +86,7 @@ public:
memory_buf_t
buf
;
fmt
::
format_to
(
buf
,
fmt
,
args
...);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
if
(
level_enabled
)
{
sink_it_
(
log_msg
);
}
if
(
tracer_
)
{
tracer_
.
push_back
(
log_msg
);
}
log_it_
(
log_msg
);
}
SPDLOG_LOGGER_CATCH
()
}
...
...
@@ -150,24 +143,14 @@ public:
template
<
class
T
,
typename
std
::
enable_if
<
std
::
is_convertible
<
const
T
&
,
spdlog
::
string_view_t
>
::
value
,
T
>::
type
*
=
nullptr
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
auto
level_enabled
=
should_log
(
lvl
);
if
(
!
level_enabled
&&
!
tracer_
)
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
())
{
return
;
}
SPDLOG_TRY
{
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
msg
);
if
(
level_enabled
)
{
sink_it_
(
log_msg
);
}
if
(
tracer_
)
{
tracer_
.
push_back
(
log_msg
);
}
}
SPDLOG_LOGGER_CATCH
()
log_it_
(
log_msg
);
}
void
log
(
level
::
level_enum
lvl
,
string_view_t
msg
)
...
...
@@ -228,8 +211,7 @@ public:
template
<
typename
...
Args
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
wstring_view_t
fmt
,
const
Args
&
...
args
)
{
auto
level_enabled
=
should_log
(
lvl
);
if
(
!
level_enabled
&&
!
tracer_
)
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
())
{
return
;
}
...
...
@@ -242,15 +224,7 @@ public:
memory_buf_t
buf
;
details
::
os
::
wstr_to_utf8buf
(
wstring_view_t
(
wbuf
.
data
(),
wbuf
.
size
()),
buf
);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
if
(
level_enabled
)
{
sink_it_
(
log_msg
);
}
if
(
tracer_
)
{
tracer_
.
push_back
(
log_msg
);
}
log_it_
(
log_msg
);
}
SPDLOG_LOGGER_CATCH
()
}
...
...
@@ -301,7 +275,7 @@ public:
template
<
class
T
,
typename
std
::
enable_if
<
is_convertible_to_wstring_view
<
const
T
&
>
::
value
,
T
>::
type
*
=
nullptr
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
if
(
!
should_log
(
lvl
))
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
()
)
{
return
;
}
...
...
@@ -310,9 +284,8 @@ public:
{
memory_buf_t
buf
;
details
::
os
::
wstr_to_utf8buf
(
msg
,
buf
);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
sink
_it_
(
log_msg
);
log
_it_
(
log_msg
);
}
SPDLOG_LOGGER_CATCH
()
}
...
...
@@ -367,6 +340,9 @@ protected:
err_handler
custom_err_handler_
{
nullptr
};
details
::
backtracer
tracer_
;
// log the given message (if the given log level is high enough),
// and save backtrace (if backtrace is enabled).
void
log_it_
(
const
details
::
log_msg
&
log_msg
);
virtual
void
sink_it_
(
const
details
::
log_msg
&
msg
);
virtual
void
flush_
();
void
dump_backtrace_
();
...
...
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