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
751520f0
Unverified
Commit
751520f0
authored
Jan 11, 2018
by
Gabi Melman
Committed by
GitHub
Jan 11, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #610 from joaomoreno/fix609
Use Sleep in Windows instead of sleep_for
parents
32177aa7
357a63d9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
6 deletions
+15
-6
async_log_helper.h
include/spdlog/details/async_log_helper.h
+2
-3
file_helper.h
include/spdlog/details/file_helper.h
+2
-2
os.h
include/spdlog/details/os.h
+9
-0
android_sink.h
include/spdlog/sinks/android_sink.h
+2
-1
No files found.
include/spdlog/details/async_log_helper.h
View file @
751520f0
...
...
@@ -358,7 +358,6 @@ inline void spdlog::details::async_log_helper::set_formatter(formatter_ptr msg_f
// spin, yield or sleep. use the time passed since last message as a hint
inline
void
spdlog
::
details
::
async_log_helper
::
sleep_or_yield
(
const
spdlog
::
log_clock
::
time_point
&
now
,
const
spdlog
::
log_clock
::
time_point
&
last_op_time
)
{
using
namespace
std
::
this_thread
;
using
std
::
chrono
::
milliseconds
;
using
std
::
chrono
::
microseconds
;
...
...
@@ -374,10 +373,10 @@ inline void spdlog::details::async_log_helper::sleep_or_yield(const spdlog::log_
// sleep for 20 ms upto 200 ms
if
(
time_since_op
<=
milliseconds
(
200
))
return
sleep_for
(
milliseconds
(
20
)
);
return
details
::
os
::
sleep_for_millis
(
20
);
// sleep for 500 ms
return
sleep_for
(
milliseconds
(
500
)
);
return
details
::
os
::
sleep_for_millis
(
500
);
}
// wait for the queue to be empty
...
...
include/spdlog/details/file_helper.h
View file @
751520f0
...
...
@@ -55,7 +55,7 @@ public:
if
(
!
os
::
fopen_s
(
&
_fd
,
fname
,
mode
))
return
;
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
open_interval
)
);
details
::
os
::
sleep_for_millis
(
open_interval
);
}
throw
spdlog_ex
(
"Failed opening file "
+
os
::
filename_to_str
(
_filename
)
+
" for writing"
,
errno
);
...
...
@@ -129,7 +129,7 @@ public:
if
(
ext_index
==
filename_t
::
npos
||
ext_index
==
0
||
ext_index
==
fname
.
size
()
-
1
)
return
std
::
make_tuple
(
fname
,
spdlog
::
filename_t
());
// treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile"
// treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile"
auto
folder_index
=
fname
.
rfind
(
details
::
os
::
folder_sep
);
if
(
folder_index
!=
fname
.
npos
&&
folder_index
>=
ext_index
-
1
)
return
std
::
make_tuple
(
fname
,
spdlog
::
filename_t
());
...
...
include/spdlog/details/os.h
View file @
751520f0
...
...
@@ -362,6 +362,15 @@ inline size_t thread_id()
}
// from https://github.com/gabime/spdlog/issues/609
inline
void
sleep_for_millis
(
int
milliseconds
)
{
#if defined(_WIN32)
Sleep
(
milliseconds
);
#else
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
milliseconds
));
#endif
}
// wchar support for windows file names (SPDLOG_WCHAR_FILENAMES must be defined)
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
...
...
include/spdlog/sinks/android_sink.h
View file @
751520f0
...
...
@@ -8,6 +8,7 @@
#if defined(__ANDROID__)
#include "sink.h"
#include "../details/os.h"
#include <mutex>
#include <string>
...
...
@@ -43,7 +44,7 @@ public:
int
retry_count
=
0
;
while
((
ret
==
-
11
/*EAGAIN*/
)
&&
(
retry_count
<
SPDLOG_ANDROID_RETRIES
))
{
std
::
this_thread
::
sleep_for
(
std
::
chrono
::
milliseconds
(
5
)
);
details
::
os
::
sleep_for_millis
(
5
);
ret
=
__android_log_write
(
priority
,
_tag
.
c_str
(),
msg_output
);
retry_count
++
;
}
...
...
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