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
0a36828f
Unverified
Commit
0a36828f
authored
Jan 19, 2020
by
Gabi Melman
Committed by
GitHub
Jan 19, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1394 from ruoshui1314/v1.x
add max files for rotating days
parents
23f0cdf9
85ea4297
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
6 deletions
+27
-6
include/spdlog/sinks/daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+27
-6
No files found.
include/spdlog/sinks/daily_file_sink.h
View file @
0a36828f
...
...
@@ -66,8 +66,7 @@ public:
if
(
max_files_
>
0
)
{
filenames_q_
=
details
::
circular_q
<
filename_t
>
(
static_cast
<
size_t
>
(
max_files_
));
filenames_q_
.
push_back
(
std
::
move
(
filename
));
init_filenames_q_
();
}
}
...
...
@@ -104,6 +103,28 @@ protected:
}
private:
void
init_filenames_q_
()
{
using
details
::
os
::
path_exists
;
filenames_q_
=
details
::
circular_q
<
filename_t
>
(
static_cast
<
size_t
>
(
max_files_
));
std
::
vector
<
filename_t
>
filenames
;
auto
now
=
log_clock
::
now
();
while
(
filenames
.
size
()
<
max_files_
)
{
auto
filename
=
FileNameCalc
::
calc_filename
(
base_filename_
,
now_tm
(
now
));
if
(
!
path_exists
(
filename
))
{
break
;
}
filenames
.
emplace_back
(
filename
);
now
-=
std
::
chrono
::
hours
(
24
);
}
for
(
auto
iter
=
filenames
.
rbegin
();
iter
!=
filenames
.
rend
();
++
iter
)
{
filenames_q_
.
push_back
(
std
::
move
(
*
iter
));
}
}
tm
now_tm
(
log_clock
::
time_point
tp
)
{
time_t
tnow
=
log_clock
::
to_time_t
(
tp
);
...
...
@@ -167,15 +188,15 @@ using daily_file_sink_st = daily_file_sink<details::null_mutex>;
//
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_mt
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
)
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
)
{
return
Factory
::
template
create
<
sinks
::
daily_file_sink_mt
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
);
return
Factory
::
template
create
<
sinks
::
daily_file_sink_mt
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
,
max_files
);
}
template
<
typename
Factory
=
spdlog
::
synchronous_factory
>
inline
std
::
shared_ptr
<
logger
>
daily_logger_st
(
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
)
const
std
::
string
&
logger_name
,
const
filename_t
&
filename
,
int
hour
=
0
,
int
minute
=
0
,
bool
truncate
=
false
,
uint16_t
max_files
=
0
)
{
return
Factory
::
template
create
<
sinks
::
daily_file_sink_st
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
);
return
Factory
::
template
create
<
sinks
::
daily_file_sink_st
>(
logger_name
,
filename
,
hour
,
minute
,
truncate
,
max_files
);
}
}
// namespace spdlog
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