Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
eb2118c1
Commit
eb2118c1
authored
May 30, 2018
by
puasonych
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update step_file_sink
parent
5c1951ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
14 deletions
+20
-14
step_file_sink.h
include/spdlog/contrib/sinks/step_file_sink.h
+20
-14
No files found.
include/spdlog/contrib/sinks/step_file_sink.h
View file @
eb2118c1
...
...
@@ -75,7 +75,15 @@ public:
{
throw
spdlog_ex
(
"step_file_sink: Invalid time step in ctor"
);
}
if
(
max_size
==
0
)
if
(
!
file_header
.
empty
())
{
pattern_formatter
formatter_for_file_header
(
"%v"
);
_file_header
.
raw
<<
file_header
;
formatter_for_file_header
.
format
(
_file_header
);
}
if
(
max_size
<=
_file_header
.
formatted
.
size
())
{
throw
spdlog_ex
(
"step_file_sink: Invalid max log size in ctor"
);
}
...
...
@@ -88,13 +96,6 @@ public:
throw
spdlog_ex
(
"step_file_sink: The temporary extension matches the specified in ctor"
);
}
if
(
!
file_header
.
empty
())
{
pattern_formatter
formatter_for_file_header
(
"%v"
);
_file_header
.
raw
<<
file_header
;
formatter_for_file_header
.
format
(
_file_header
);
}
_file_helper
.
open
(
_current_filename
);
_current_size
=
_file_helper
.
size
();
// expensive. called only once
...
...
@@ -120,14 +121,19 @@ protected:
if
(
std
::
chrono
::
system_clock
::
now
()
>=
_tp
||
_current_size
+
msg_size
>
_max_size
)
{
close_current_file
();
filename_t
new_filename
;
std
::
tie
(
new_filename
,
std
::
ignore
)
=
FileNameCalc
::
calc_filename
(
_base_filename
,
_tmp_ext
);
if
(
new_filename
!=
_current_filename
)
{
close_current_file
();
std
::
tie
(
_current_filename
,
std
::
ignore
)
=
FileNameCalc
::
calc_filename
(
_base_filename
,
_tmp_ext
);
_file_helper
.
open
(
_current_filename
);
_tp
=
_next_tp
();
//
std::tie(_current_filename, std::ignore) = FileNameCalc::calc_filename(_base_filename, _tmp_ext);
_file_helper
.
open
(
_current_filename
);
_tp
=
_next_tp
();
_current_size
=
_file_header
.
formatted
.
size
();
if
(
_current_size
)
_file_helper
.
write
(
_file_header
);
_current_size
=
_file_header
.
formatted
.
size
();
if
(
_current_size
)
_file_helper
.
write
(
_file_header
);
}
}
_current_size
+=
msg_size
;
...
...
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