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
79468cf6
Commit
79468cf6
authored
Nov 03, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Micro-optimze log_it_
parent
4037942a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
12 deletions
+20
-12
include/spdlog/logger-inl.h
include/spdlog/logger-inl.h
+3
-3
include/spdlog/logger.h
include/spdlog/logger.h
+17
-9
No files found.
include/spdlog/logger-inl.h
View file @
79468cf6
...
@@ -172,13 +172,13 @@ SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
...
@@ -172,13 +172,13 @@ SPDLOG_INLINE std::shared_ptr<logger> logger::clone(std::string logger_name)
}
}
// protected methods
// protected methods
SPDLOG_INLINE
void
logger
::
log_it_
(
const
details
::
log_msg
&
log_msg
)
SPDLOG_INLINE
void
logger
::
log_it_
(
const
spdlog
::
details
::
log_msg
&
log_msg
,
bool
log_enabled
,
bool
traceback_enabled
)
{}(
const
details
::
log_msg
&
log_msg
,
bool
log_enabled
,
bool
traceback_enabled
)
{
{
if
(
should_log
(
log_msg
.
level
)
)
if
(
log_enabled
)
{
{
sink_it_
(
log_msg
);
sink_it_
(
log_msg
);
}
}
if
(
trace
r_
.
enabled
()
)
if
(
trace
back_enabled
)
{
{
tracer_
.
push_back
(
log_msg
);
tracer_
.
push_back
(
log_msg
);
}
}
...
...
include/spdlog/logger.h
View file @
79468cf6
...
@@ -76,7 +76,9 @@ public:
...
@@ -76,7 +76,9 @@ public:
template
<
typename
...
Args
>
template
<
typename
...
Args
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
string_view_t
fmt
,
const
Args
&
...
args
)
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
string_view_t
fmt
,
const
Args
&
...
args
)
{
{
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
())
bool
log_enabled
=
should_log
(
lvl
);
bool
traceback_enabled
=
tracer_
.
enabled
();
if
(
!
log_enabled
&&
!
traceback_enabled
)
{
{
return
;
return
;
}
}
...
@@ -85,7 +87,7 @@ public:
...
@@ -85,7 +87,7 @@ public:
memory_buf_t
buf
;
memory_buf_t
buf
;
fmt
::
format_to
(
buf
,
fmt
,
args
...);
fmt
::
format_to
(
buf
,
fmt
,
args
...);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
log_it_
(
log_msg
);
log_it_
(
log_msg
,
log_enabled
,
traceback_enabled
);
}
}
SPDLOG_LOGGER_CATCH
()
SPDLOG_LOGGER_CATCH
()
}
}
...
@@ -142,13 +144,15 @@ public:
...
@@ -142,13 +144,15 @@ public:
template
<
class
T
,
typename
std
::
enable_if
<
std
::
is_convertible
<
const
T
&
,
spdlog
::
string_view_t
>
::
value
,
T
>::
type
*
=
nullptr
>
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
)
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
{
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
())
bool
log_enabled
=
should_log
(
lvl
);
bool
traceback_enabled
=
tracer_
.
enabled
();
if
(
!
log_enabled
&&
!
traceback_enabled
)
{
{
return
;
return
;
}
}
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
msg
);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
msg
);
log_it_
(
log_msg
);
log_it_
(
log_msg
,
log_enabled
,
traceback_enabled
);
}
}
void
log
(
level
::
level_enum
lvl
,
string_view_t
msg
)
void
log
(
level
::
level_enum
lvl
,
string_view_t
msg
)
...
@@ -209,7 +213,9 @@ public:
...
@@ -209,7 +213,9 @@ public:
template
<
typename
...
Args
>
template
<
typename
...
Args
>
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
wstring_view_t
fmt
,
const
Args
&
...
args
)
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
wstring_view_t
fmt
,
const
Args
&
...
args
)
{
{
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
())
bool
log_enabled
=
should_log
(
lvl
);
bool
traceback_enabled
=
tracer_
.
enabled
();
if
(
!
log_enabled
&&
!
traceback_enabled
)
{
{
return
;
return
;
}
}
...
@@ -222,7 +228,7 @@ public:
...
@@ -222,7 +228,7 @@ public:
memory_buf_t
buf
;
memory_buf_t
buf
;
details
::
os
::
wstr_to_utf8buf
(
wstring_view_t
(
wbuf
.
data
(),
wbuf
.
size
()),
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
()));
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
log_it_
(
log_msg
);
log_it_
(
log_msg
,
log_enabled
,
traceback_enabled
);
}
}
SPDLOG_LOGGER_CATCH
()
SPDLOG_LOGGER_CATCH
()
}
}
...
@@ -273,7 +279,9 @@ public:
...
@@ -273,7 +279,9 @@ public:
template
<
class
T
,
typename
std
::
enable_if
<
is_convertible_to_wstring_view
<
const
T
&
>
::
value
,
T
>::
type
*
=
nullptr
>
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
)
void
log
(
source_loc
loc
,
level
::
level_enum
lvl
,
const
T
&
msg
)
{
{
if
(
!
should_log
(
lvl
)
&&
!
tracer_
.
enabled
())
bool
log_enabled
=
should_log
(
lvl
);
bool
traceback_enabled
=
tracer_
.
enabled
();
if
(
!
log_enabled
&&
!
traceback_enabled
)
{
{
return
;
return
;
}
}
...
@@ -283,7 +291,7 @@ public:
...
@@ -283,7 +291,7 @@ public:
memory_buf_t
buf
;
memory_buf_t
buf
;
details
::
os
::
wstr_to_utf8buf
(
msg
,
buf
);
details
::
os
::
wstr_to_utf8buf
(
msg
,
buf
);
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
details
::
log_msg
log_msg
(
loc
,
name_
,
lvl
,
string_view_t
(
buf
.
data
(),
buf
.
size
()));
log_it_
(
log_msg
);
log_it_
(
log_msg
,
log_enabled
,
traceback_enabled
);
}
}
SPDLOG_LOGGER_CATCH
()
SPDLOG_LOGGER_CATCH
()
}
}
...
@@ -340,7 +348,7 @@ protected:
...
@@ -340,7 +348,7 @@ protected:
// log the given message (if the given log level is high enough),
// log the given message (if the given log level is high enough),
// and save backtrace (if backtrace is enabled).
// and save backtrace (if backtrace is enabled).
void
log_it_
(
const
details
::
log_msg
&
log_msg
);
void
log_it_
(
const
details
::
log_msg
&
log_msg
,
bool
log_enabled
,
bool
traceback_enabled
);
virtual
void
sink_it_
(
const
details
::
log_msg
&
msg
);
virtual
void
sink_it_
(
const
details
::
log_msg
&
msg
);
virtual
void
flush_
();
virtual
void
flush_
();
void
dump_backtrace_
();
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