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
701ef172
Commit
701ef172
authored
Nov 16, 2021
by
Charles Milette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move strftime to daily_filename_format_calculator
parent
5d6af189
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
19 deletions
+22
-19
include/spdlog/details/fmt_helper.h
include/spdlog/details/fmt_helper.h
+0
-17
include/spdlog/sinks/daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+22
-2
No files found.
include/spdlog/details/fmt_helper.h
View file @
701ef172
...
...
@@ -164,23 +164,6 @@ inline ToDuration time_fraction(log_clock::time_point tp)
return
duration_cast
<
ToDuration
>
(
duration
)
-
duration_cast
<
ToDuration
>
(
secs
);
}
inline
size_t
strftime
(
char
*
str
,
size_t
count
,
const
char
*
format
,
const
std
::
tm
*
time
)
{
// Assign to a pointer to suppress GCCs -Wformat-nonliteral
// First assign the nullptr to suppress -Wsuggest-attribute=format
std
::
size_t
(
*
strftime
)(
char
*
,
std
::
size_t
,
const
char
*
,
const
std
::
tm
*
)
=
nullptr
;
strftime
=
std
::
strftime
;
return
strftime
(
str
,
count
,
format
,
time
);
}
inline
size_t
strftime
(
wchar_t
*
str
,
size_t
count
,
const
wchar_t
*
format
,
const
std
::
tm
*
time
)
{
// See above
std
::
size_t
(
*
wcsftime
)(
wchar_t
*
,
std
::
size_t
,
const
wchar_t
*
,
const
std
::
tm
*
)
=
nullptr
;
wcsftime
=
std
::
wcsftime
;
return
wcsftime
(
str
,
count
,
format
,
time
);
}
}
// namespace fmt_helper
}
// namespace details
}
// namespace spdlog
include/spdlog/sinks/daily_file_sink.h
View file @
701ef172
...
...
@@ -62,7 +62,7 @@ struct daily_filename_format_calculator
buf
.
resize
(
MIN_SIZE
);
for
(;;)
{
size_t
count
=
details
::
fmt_helper
::
strftime
(
buf
.
data
(),
buf
.
size
(),
tm_format
.
c_str
(),
&
now_tm
);
size_t
count
=
strftime
(
buf
.
data
(),
buf
.
size
(),
tm_format
.
c_str
(),
&
now_tm
);
if
(
count
!=
0
)
{
// Remove the extra space.
...
...
@@ -87,7 +87,7 @@ struct daily_filename_format_calculator
for
(;;)
{
size_t
size
=
buf
.
capacity
()
-
start
;
size_t
count
=
details
::
fmt_helper
::
strftime
(
&
buf
[
start
],
size
,
&
tm_format
[
0
],
&
now_tm
);
size_t
count
=
strftime
(
&
buf
[
start
],
size
,
&
tm_format
[
0
],
&
now_tm
);
if
(
count
!=
0
)
{
// Remove the extra space.
...
...
@@ -101,6 +101,26 @@ struct daily_filename_format_calculator
return
fmt
::
to_string
(
buf
);
#endif
}
private:
#if defined __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
static
size_t
strftime
(
char
*
str
,
size_t
count
,
const
char
*
format
,
const
std
::
tm
*
time
)
{
return
std
::
strftime
(
str
,
count
,
format
,
time
);
}
static
size_t
strftime
(
wchar_t
*
str
,
size_t
count
,
const
wchar_t
*
format
,
const
std
::
tm
*
time
)
{
return
std
::
wcsftime
(
str
,
count
,
format
,
time
);
}
#if defined(__GNUC__)
# pragma GCC diagnostic pop
#endif
};
/*
...
...
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