Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Fischer
emper
Commits
7416e2f9
Commit
7416e2f9
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
[log] Improve timestamp format: HHMM.SS mmmuuunnn
parent
4d90dfc0
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
emper/log/log.cpp
+5
-6
5 additions, 6 deletions
emper/log/log.cpp
with
5 additions
and
6 deletions
emper/log/log.cpp
+
5
−
6
View file @
7416e2f9
// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright © 2020 Florian Schmaus
// Copyright © 2021 Florian Fischer
// Copyright © 2020-2022 Florian Schmaus, Florian Fischer
#include
"log.hpp"
#include
<pthread.h>
...
...
@@ -44,15 +43,15 @@ static void add_timestamp_to(std::ostringstream& logMessage) {
}
}();
logMessage
<<
std
::
put_time
(
now_localtime
,
"%H%M."
);
logMessage
<<
std
::
put_time
(
now_localtime
,
"%H%M.
%S
"
);
auto
now_nanos
=
std
::
chrono
::
time_point_cast
<
std
::
chrono
::
nanoseconds
>
(
now
);
auto
time_since_epoch
=
now_nanos
.
time_since_epoch
();
long
time_since_epoch_long
=
time_since_epoch
.
count
();
const
long
NanosInA
Minute
=
60L
*
1000
*
1000
*
1000
;
long
remaining_nanos
=
time_since_epoch_long
%
NanosInA
Minute
;
logMessage
<<
remaining_nanos
;
const
expr
long
NanosInA
Second
=
1000
L
*
1000
*
1000
;
long
remaining_nanos
=
time_since_epoch_long
%
NanosInA
Second
;
logMessage
<<
" "
<<
std
::
setfill
(
'0'
)
<<
std
::
setw
(
9
)
<<
remaining_nanos
;
}
static
std
::
mutex
log_mutex
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment