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
ba120e52
Commit
ba120e52
authored
Nov 15, 2021
by
Charless Milette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unit test for daily_filename_format_calculator
parent
a6945d04
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
include/spdlog/sinks/daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+1
-1
tests/test_daily_logger.cpp
tests/test_daily_logger.cpp
+10
-0
No files found.
include/spdlog/sinks/daily_file_sink.h
View file @
ba120e52
...
...
@@ -75,7 +75,7 @@ struct daily_filename_format_calculator
return
buf
;
#else
fmt
::
basic_memory_buffer
<
filename_t
::
value_type
>
tm_format
;
tm_format
.
append
(
specs
.
begin
(),
specs
.
end
());
tm_format
.
append
(
filename
.
c_str
(),
filename
.
c_str
()
+
filename
.
size
());
// By appending an extra space we can distinguish an empty result that
// indicates insufficient buffer size from a guaranteed non-empty result
// https://github.com/fmtlib/fmt/issues/2238
...
...
tests/test_daily_logger.cpp
View file @
ba120e52
...
...
@@ -142,6 +142,16 @@ TEST_CASE("daily_file_sink::daily_filename_calculator", "[daily_file_sink]]")
}
#endif
TEST_CASE
(
"daily_file_sink::daily_filename_format_calculator"
,
"[daily_file_sink]]"
)
{
std
::
tm
tm
=
spdlog
::
details
::
os
::
localtime
();
// example-YYYY-MM-DD.log
auto
filename
=
spdlog
::
sinks
::
daily_filename_format_calculator
::
calc_filename
(
SPDLOG_FILENAME_T
(
"example-%Y-%m-%d.log"
),
tm
);
REQUIRE
(
filename
==
spdlog
::
fmt_lib
::
format
(
SPDLOG_FILENAME_T
(
"example-{:04d}-{:02d}-{:02d}.log"
),
tm
.
tm_year
+
1900
,
tm
.
tm_mon
+
1
,
tm
.
tm_mday
));
}
/* Test removal of old files */
static
spdlog
::
details
::
log_msg
create_msg
(
std
::
chrono
::
seconds
offset
)
{
...
...
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