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
40010328
Commit
40010328
authored
Nov 16, 2021
by
Charles Milette
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add attribution, return to previous code for daily_filename_format_calculator with fmtlib
parent
ad779e48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
28 deletions
+11
-28
include/spdlog/details/fmt_helper.h
include/spdlog/details/fmt_helper.h
+1
-1
include/spdlog/sinks/daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+10
-27
No files found.
include/spdlog/details/fmt_helper.h
View file @
40010328
...
...
@@ -59,7 +59,7 @@ inline void append_int(T n, memory_buf_t &dest)
template
<
typename
T
>
SPDLOG_CONSTEXPR_FUNC
unsigned
int
count_digits_fallback
(
T
n
)
{
// taken from fmt
.
// taken from fmt
: https://github.com/fmtlib/fmt/blob/8.0.1/include/fmt/format.h#L899-L912
unsigned
int
count
=
1
;
for
(;;)
{
...
...
include/spdlog/sinks/daily_file_sink.h
View file @
40010328
...
...
@@ -5,9 +5,9 @@
#include <spdlog/common.h>
#include <spdlog/details/file_helper.h>
#include <spdlog/details/fmt_helper.h>
#include <spdlog/details/null_mutex.h>
#include <spdlog/fmt/fmt.h>
#include <spdlog/fmt/chrono.h>
#include <spdlog/sinks/base_sink.h>
#include <spdlog/details/os.h>
#include <spdlog/details/circular_q.h>
...
...
@@ -48,8 +48,9 @@ struct daily_filename_format_calculator
{
static
filename_t
calc_filename
(
const
filename_t
&
filename
,
const
tm
&
now_tm
)
{
// adapted from fmtlib
#ifdef SPDLOG_USE_STD_FORMAT
// adapted from fmtlib: https://github.com/fmtlib/fmt/blob/8.0.1/include/fmt/chrono.h#L522-L546
filename_t
tm_format
;
tm_format
.
append
(
filename
);
// By appending an extra space we can distinguish an empty result that
...
...
@@ -74,31 +75,13 @@ struct daily_filename_format_calculator
return
buf
;
#else
fmt
::
basic_memory_buffer
<
filename_t
::
value_type
>
tm_format
;
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
tm_format
.
push_back
(
' '
);
tm_format
.
push_back
(
'\0'
);
fmt
::
basic_memory_buffer
<
filename_t
::
value_type
>
buf
;
size_t
start
=
buf
.
size
();
for
(;;)
{
size_t
size
=
buf
.
capacity
()
-
start
;
size_t
count
=
strftime
(
&
buf
[
start
],
size
,
&
tm_format
[
0
],
&
now_tm
);
if
(
count
!=
0
)
{
// Remove the extra space.
buf
.
resize
(
start
+
count
-
1
);
break
;
}
const
size_t
MIN_GROWTH
=
10
;
buf
.
reserve
(
buf
.
capacity
()
+
(
size
>
MIN_GROWTH
?
size
:
MIN_GROWTH
));
}
return
fmt
::
to_string
(
buf
);
// generate fmt datetime format string, e.g. {:%Y-%m-%d}.
filename_t
fmt_filename
=
fmt
::
format
(
SPDLOG_FILENAME_T
(
"{{:{}}}"
),
filename
);
# if defined(_MSC_VER) && defined(SPDLOG_WCHAR_FILENAMES) // for some reason msvc doesn't allow fmt::runtime(..) with wchar here
return
fmt
::
format
(
fmt_filename
,
now_tm
);
# else
return
fmt
::
format
(
SPDLOG_FMT_RUNTIME
(
fmt_filename
),
now_tm
);
# endif
#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