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
81444265
Commit
81444265
authored
Apr 19, 2020
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clang-format
parent
5716ab70
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
111 additions
and
102 deletions
+111
-102
include/spdlog/details/log_msg-inl.h
include/spdlog/details/log_msg-inl.h
+2
-2
include/spdlog/pattern_formatter-inl.h
include/spdlog/pattern_formatter-inl.h
+5
-4
src/fmt.cpp
src/fmt.cpp
+86
-79
tests/test_time_point.cpp
tests/test_time_point.cpp
+18
-17
No files found.
include/spdlog/details/log_msg-inl.h
View file @
81444265
...
...
@@ -12,8 +12,8 @@
namespace
spdlog
{
namespace
details
{
SPDLOG_INLINE
log_msg
::
log_msg
(
spdlog
::
l
og_clock
::
time_point
log_time
,
spdlog
::
source_loc
loc
,
string_view_t
a_logger_name
,
spdlog
::
l
evel
::
level_enum
lvl
,
spdlog
::
string_view_t
msg
)
SPDLOG_INLINE
log_msg
::
log_msg
(
spdlog
::
log_clock
::
time_point
log_time
,
spdlog
::
source_loc
loc
,
string_view_t
a_logger_name
,
spdlog
::
level
::
level_enum
lvl
,
spdlog
::
string_view_t
msg
)
:
logger_name
(
a_logger_name
)
,
level
(
lvl
)
,
time
(
log_time
)
...
...
include/spdlog/pattern_formatter-inl.h
View file @
81444265
...
...
@@ -95,7 +95,10 @@ struct null_scoped_padder
null_scoped_padder
(
size_t
/*wrapped_size*/
,
const
padding_info
&
/*padinfo*/
,
memory_buf_t
&
/*dest*/
)
{}
template
<
typename
T
>
static
unsigned
int
count_digits
(
T
/* number */
)
{
return
0
;}
static
unsigned
int
count_digits
(
T
/* number */
)
{
return
0
;
}
};
template
<
typename
ScopedPadder
>
...
...
@@ -653,7 +656,6 @@ public:
}
};
// Current pid
template
<
typename
ScopedPadder
>
class
pid_formatter
final
:
public
flag_formatter
...
...
@@ -766,7 +768,7 @@ public:
}
size_t
text_size
;
if
(
padinfo_
.
enabled
())
if
(
padinfo_
.
enabled
())
{
// calc text size for padding based on "filename:line"
text_size
=
std
::
char_traits
<
char
>::
length
(
msg
.
source
.
filename
)
+
ScopedPadder
::
count_digits
(
msg
.
source
.
line
)
+
1
;
...
...
@@ -900,7 +902,6 @@ private:
log_clock
::
time_point
last_message_time_
;
};
// Full info formatter
// pattern: [%Y-%m-%d %H:%M:%S.%e] [%n] [%l] %v
class
full_formatter
final
:
public
flag_formatter
...
...
src/fmt.cpp
View file @
81444265
This diff is collapsed.
Click to expand it.
tests/test_time_point.cpp
View file @
81444265
...
...
@@ -4,28 +4,29 @@
TEST_CASE
(
"time_point1"
,
"[time_point log_msg]"
)
{
std
::
shared_ptr
<
spdlog
::
sinks
::
test_sink_st
>
test_sink
(
new
spdlog
::
sinks
::
test_sink_st
);
spdlog
::
logger
logger
(
"test-time_point"
,
test_sink
);
std
::
shared_ptr
<
spdlog
::
sinks
::
test_sink_st
>
test_sink
(
new
spdlog
::
sinks
::
test_sink_st
);
spdlog
::
logger
logger
(
"test-time_point"
,
test_sink
);
spdlog
::
source_loc
source
{};
std
::
chrono
::
system_clock
::
time_point
tp
{
std
::
chrono
::
system_clock
::
now
()};
spdlog
::
source_loc
source
{};
std
::
chrono
::
system_clock
::
time_point
tp
{
std
::
chrono
::
system_clock
::
now
()};
test_sink
->
set_pattern
(
"%T.%F"
);
// interested in the time_point
// all the following should have the same time
test_sink
->
set_delay
(
std
::
chrono
::
milliseconds
(
10
));
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
spdlog
::
details
::
log_msg
msg
{
tp
,
source
,
"test_logger"
,
spdlog
::
level
::
info
,
"message"
};
// all the following should have the same time
test_sink
->
set_delay
(
std
::
chrono
::
milliseconds
(
10
));
for
(
int
i
=
0
;
i
<
5
;
i
++
)
{
spdlog
::
details
::
log_msg
msg
{
tp
,
source
,
"test_logger"
,
spdlog
::
level
::
info
,
"message"
};
test_sink
->
log
(
msg
);
}
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
source
,
spdlog
::
level
::
info
,
"formatted message"
);
// last line has different time_point
}
// now the real test... that the times are the same.
std
::
vector
<
std
::
string
>
lines
=
test_sink
->
lines
();
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
tp
,
source
,
spdlog
::
level
::
info
,
"formatted message"
);
logger
.
log
(
source
,
spdlog
::
level
::
info
,
"formatted message"
);
// last line has different time_point
// now the real test... that the times are the same.
std
::
vector
<
std
::
string
>
lines
=
test_sink
->
lines
();
REQUIRE
(
lines
[
0
]
==
lines
[
1
]);
REQUIRE
(
lines
[
2
]
==
lines
[
3
]);
REQUIRE
(
lines
[
4
]
==
lines
[
5
]);
...
...
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