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
2f34de82
Commit
2f34de82
authored
Jan 27, 2015
by
Denis Ivaykin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coarse clock, short log level
parent
a788fb3e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
include/spdlog/common.h
include/spdlog/common.h
+7
-0
include/spdlog/details/line_logger.h
include/spdlog/details/line_logger.h
+11
-0
include/spdlog/details/pattern_formatter_impl.h
include/spdlog/details/pattern_formatter_impl.h
+13
-0
No files found.
include/spdlog/common.h
View file @
2f34de82
...
...
@@ -71,10 +71,17 @@ typedef enum
static
const
char
*
level_names
[]
{
"trace"
,
"debug"
,
"info"
,
"notice"
,
"warning"
,
"error"
,
"critical"
,
"alert"
,
"emerg"
,
"off"
};
static
const
char
*
short_level_names
[]
{
"T"
,
"D"
,
"I"
,
"N"
,
"W"
,
"E"
,
"C"
,
"A"
,
"M"
,
"O"
};
inline
const
char
*
to_str
(
spdlog
::
level
::
level_enum
l
)
{
return
level_names
[
l
];
}
inline
const
char
*
to_short_str
(
spdlog
::
level
::
level_enum
l
)
{
return
short_level_names
[
l
];
}
}
//level
...
...
include/spdlog/details/line_logger.h
View file @
2f34de82
...
...
@@ -26,6 +26,9 @@
#include "../common.h"
#include "../logger.h"
#ifdef SPDLOG_CLOCK_COARSE
#include <time.h>
#endif
// Line logger class - aggregates operator<< calls to fast ostream
...
...
@@ -64,7 +67,15 @@ public:
if
(
_enabled
)
{
_log_msg
.
logger_name
=
_callback_logger
->
name
();
#ifndef SPDLOG_CLOCK_COARSE
_log_msg
.
time
=
log_clock
::
now
();
#else
timespec
ts
;
::
clock_gettime
(
CLOCK_REALTIME_COARSE
,
&
ts
);
_log_msg
.
time
=
std
::
chrono
::
time_point
<
log_clock
,
typename
log_clock
::
duration
>
(
std
::
chrono
::
duration_cast
<
typename
log_clock
::
duration
>
(
std
::
chrono
::
seconds
(
ts
.
tv_sec
)
+
std
::
chrono
::
nanoseconds
(
ts
.
tv_nsec
)));
#endif
_callback_logger
->
_log_msg
(
_log_msg
);
}
}
...
...
include/spdlog/details/pattern_formatter_impl.h
View file @
2f34de82
...
...
@@ -69,6 +69,15 @@ class level_formatter :public flag_formatter
}
};
// short log level appender
class
short_level_formatter
:
public
flag_formatter
{
void
format
(
details
::
log_msg
&
msg
,
const
std
::
tm
&
)
override
{
msg
.
formatted
<<
level
::
to_short_str
(
msg
.
level
);
}
};
///////////////////////////////////////////////////////////////////////
// Date time pattern appenders
///////////////////////////////////////////////////////////////////////
...
...
@@ -478,6 +487,10 @@ inline void spdlog::pattern_formatter::handle_flag(char flag)
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
level_formatter
()));
break
;
case
'L'
:
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
short_level_formatter
()));
break
;
case
(
't'
)
:
_formatters
.
push_back
(
std
::
unique_ptr
<
details
::
flag_formatter
>
(
new
details
::
t_formatter
()));
break
;
...
...
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