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
0f73cd2a
Commit
0f73cd2a
authored
Sep 16, 2021
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplified default error handler
parent
686b8a46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
16 deletions
+4
-16
include/spdlog/logger-inl.h
include/spdlog/logger-inl.h
+4
-16
No files found.
include/spdlog/logger-inl.h
View file @
0f73cd2a
...
@@ -10,7 +10,6 @@
...
@@ -10,7 +10,6 @@
#include <spdlog/sinks/sink.h>
#include <spdlog/sinks/sink.h>
#include <cstdio>
#include <cstdio>
#include <mutex>
namespace
spdlog
{
namespace
spdlog
{
...
@@ -184,25 +183,14 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg)
...
@@ -184,25 +183,14 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg)
}
}
else
else
{
{
using
std
::
chrono
::
system_clock
;
auto
now
=
log_clock
::
now
();
static
std
::
mutex
mutex
;
auto
tm_time
=
details
::
os
::
localtime
(
log_clock
::
to_time_t
(
now
));
static
std
::
chrono
::
system_clock
::
time_point
last_report_time
;
static
size_t
err_counter
=
0
;
std
::
lock_guard
<
std
::
mutex
>
lk
{
mutex
};
auto
now
=
system_clock
::
now
();
err_counter
++
;
if
(
now
-
last_report_time
<
std
::
chrono
::
seconds
(
1
))
{
return
;
}
last_report_time
=
now
;
auto
tm_time
=
details
::
os
::
localtime
(
system_clock
::
to_time_t
(
now
));
char
date_buf
[
64
];
char
date_buf
[
64
];
std
::
strftime
(
date_buf
,
sizeof
(
date_buf
),
"%Y-%m-%d %H:%M:%S"
,
&
tm_time
);
std
::
strftime
(
date_buf
,
sizeof
(
date_buf
),
"%Y-%m-%d %H:%M:%S"
,
&
tm_time
);
#if defined(USING_R) && defined(R_R_H) // if in R environment
#if defined(USING_R) && defined(R_R_H) // if in R environment
REprintf
(
"[*** LOG ERROR
#%04zu ***] [%s] [%s] {%s}
\n
"
,
err_counter
,
date_buf
,
name
().
c_str
(),
msg
.
c_str
());
REprintf
(
"[*** LOG ERROR
***] [%s] [%s] {%s}
\n
"
,
date_buf
,
name
().
c_str
(),
msg
.
c_str
());
#else
#else
std
::
fprintf
(
stderr
,
"[*** LOG ERROR
#%04zu ***] [%s] [%s] {%s}
\n
"
,
err_counter
,
date_buf
,
name
().
c_str
(),
msg
.
c_str
());
std
::
fprintf
(
stderr
,
"[*** LOG ERROR
***] [%s] [%s] {%s}
\n
"
,
date_buf
,
name
().
c_str
(),
msg
.
c_str
());
#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