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
1b2c8b9d
Commit
1b2c8b9d
authored
May 12, 2015
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored periodic flush in async_log_helper
parent
e6fc8bf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
11 deletions
+15
-11
include/spdlog/details/async_log_helper.h
include/spdlog/details/async_log_helper.h
+15
-11
No files found.
include/spdlog/details/async_log_helper.h
View file @
1b2c8b9d
...
@@ -66,7 +66,7 @@ class async_log_helper
...
@@ -66,7 +66,7 @@ class async_log_helper
async_msg
()
=
default
;
async_msg
()
=
default
;
~
async_msg
()
=
default
;
~
async_msg
()
=
default
;
async_msg
(
async_msg
&&
other
)
SPDLOG_NOEXCEPT
:
async_msg
(
async_msg
&&
other
)
SPDLOG_NOEXCEPT
:
logger_name
(
std
::
move
(
other
.
logger_name
)),
logger_name
(
std
::
move
(
other
.
logger_name
)),
level
(
std
::
move
(
other
.
level
)),
level
(
std
::
move
(
other
.
level
)),
time
(
std
::
move
(
other
.
time
)),
time
(
std
::
move
(
other
.
time
)),
...
@@ -163,9 +163,13 @@ private:
...
@@ -163,9 +163,13 @@ private:
// return true if a message was available (queue was not empty), will set the last_pop to the pop time
// return true if a message was available (queue was not empty), will set the last_pop to the pop time
bool
process_next_msg
(
log_clock
::
time_point
&
last_pop
,
log_clock
::
time_point
&
last_flush
);
bool
process_next_msg
(
log_clock
::
time_point
&
last_pop
,
log_clock
::
time_point
&
last_flush
);
void
handle_flush_interval
(
log_clock
::
time_point
&
now
,
log_clock
::
time_point
&
last_flush
);
// sleep,yield or return immediatly using the time passed since last message as a hint
// sleep,yield or return immediatly using the time passed since last message as a hint
static
void
sleep_or_yield
(
const
spdlog
::
log_clock
::
time_point
&
now
,
const
log_clock
::
time_point
&
last_op_time
);
static
void
sleep_or_yield
(
const
spdlog
::
log_clock
::
time_point
&
now
,
const
log_clock
::
time_point
&
last_op_time
);
};
};
}
}
}
}
...
@@ -259,21 +263,21 @@ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_
...
@@ -259,21 +263,21 @@ inline bool spdlog::details::async_log_helper::process_next_msg(log_clock::time_
else
//empty queue
else
//empty queue
{
{
auto
now
=
details
::
os
::
now
();
auto
now
=
details
::
os
::
now
();
if
(
_flush_interval_ms
>
std
::
chrono
::
milliseconds
::
zero
())
handle_flush_interval
(
now
,
last_flush
);
{
auto
time_since_flush
=
now
-
last_flush
;
if
(
time_since_flush
>=
_flush_interval_ms
)
{
last_flush
=
now
;
for
(
auto
&
s
:
_sinks
)
s
->
flush
();
}
}
sleep_or_yield
(
now
,
last_pop
);
sleep_or_yield
(
now
,
last_pop
);
}
}
return
true
;
return
true
;
}
}
inline
void
spdlog
::
details
::
async_log_helper
::
handle_flush_interval
(
log_clock
::
time_point
&
now
,
log_clock
::
time_point
&
last_flush
)
{
if
(
_flush_interval_ms
!=
std
::
chrono
::
milliseconds
::
zero
()
&&
now
-
last_flush
>=
_flush_interval_ms
)
{
for
(
auto
&
s
:
_sinks
)
s
->
flush
();
now
=
last_flush
=
details
::
os
::
now
();
}
}
inline
void
spdlog
::
details
::
async_log_helper
::
set_formatter
(
formatter_ptr
msg_formatter
)
inline
void
spdlog
::
details
::
async_log_helper
::
set_formatter
(
formatter_ptr
msg_formatter
)
{
{
_formatter
=
msg_formatter
;
_formatter
=
msg_formatter
;
...
...
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