Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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
cpp-libs
Actor Framework
Commits
72c449ec
Commit
72c449ec
authored
Jun 29, 2017
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix logger on GCC 4.8
parent
a4aa1c36
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
libcaf_core/src/logger.cpp
libcaf_core/src/logger.cpp
+6
-1
libcaf_core/test/logger.cpp
libcaf_core/test/logger.cpp
+6
-4
No files found.
libcaf_core/src/logger.cpp
View file @
72c449ec
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
#include "caf/logger.hpp"
#include "caf/logger.hpp"
#include <ctime>
#include <thread>
#include <thread>
#include <cstring>
#include <cstring>
#include <iomanip>
#include <iomanip>
...
@@ -292,7 +293,11 @@ void logger::render_time_diff(std::ostream& out, timestamp t0, timestamp tn) {
...
@@ -292,7 +293,11 @@ void logger::render_time_diff(std::ostream& out, timestamp t0, timestamp tn) {
void
logger
::
render_date
(
std
::
ostream
&
out
,
timestamp
x
)
{
void
logger
::
render_date
(
std
::
ostream
&
out
,
timestamp
x
)
{
auto
y
=
std
::
chrono
::
time_point_cast
<
timestamp
::
clock
::
duration
>
(
x
);
auto
y
=
std
::
chrono
::
time_point_cast
<
timestamp
::
clock
::
duration
>
(
x
);
auto
z
=
timestamp
::
clock
::
to_time_t
(
y
);
auto
z
=
timestamp
::
clock
::
to_time_t
(
y
);
out
<<
std
::
put_time
(
std
::
localtime
(
&
z
),
"%F %T"
);
// strftime workaround: std::put_time not available on GCC 4.8
// out << std::put_time(std::localtime(&z), "%F %T");
char
buf
[
50
];
if
(
strftime
(
buf
,
sizeof
(
buf
),
"%Y-%m-%d %H:%M:%S"
,
std
::
localtime
(
&
z
)))
out
<<
buf
;
}
}
void
logger
::
render
(
std
::
ostream
&
out
,
const
line_format
&
lf
,
void
logger
::
render
(
std
::
ostream
&
out
,
const
line_format
&
lf
,
...
...
libcaf_core/test/logger.cpp
View file @
72c449ec
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#define CAF_SUITE logger
#define CAF_SUITE logger
#include "caf/test/unit_test.hpp"
#include "caf/test/unit_test.hpp"
#include <ctime>
#include <string>
#include <string>
#include "caf/all.hpp"
#include "caf/all.hpp"
...
@@ -99,10 +100,11 @@ CAF_TEST(rendering) {
...
@@ -99,10 +100,11 @@ CAF_TEST(rendering) {
timestamp
t0
;
timestamp
t0
;
timestamp
t1
{
timestamp
::
duration
{
5000000
}};
// epoch + 5000000ns (5ms)
timestamp
t1
{
timestamp
::
duration
{
5000000
}};
// epoch + 5000000ns (5ms)
CAF_CHECK_EQUAL
(
render
(
logger
::
render_time_diff
,
t0
,
t1
),
"5"
);
CAF_CHECK_EQUAL
(
render
(
logger
::
render_time_diff
,
t0
,
t1
),
"5"
);
ostringstream
t0_iso8601
;
time_t
t0_t
=
0
;
auto
t0_t
=
system_clock
::
to_time_t
(
system_clock
::
time_point
{});
char
t0_buf
[
50
];
t0_iso8601
<<
put_time
(
localtime
(
&
t0_t
),
"%F %T"
);
CAF_REQUIRE
(
strftime
(
t0_buf
,
sizeof
(
t0_buf
),
CAF_CHECK_EQUAL
(
render
(
logger
::
render_date
,
t0
),
t0_iso8601
.
str
());
"%Y-%m-%d %H:%M:%S"
,
localtime
(
&
t0_t
)));
CAF_CHECK_EQUAL
(
render
(
logger
::
render_date
,
t0
),
t0_buf
);
// Rendering of events.
// Rendering of events.
logger
::
event
e
{
logger
::
event
e
{
nullptr
,
nullptr
,
...
...
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