Comments (5)
Also affected on windows VS2015, I get time stamps as [1970-01-02 06:01:03.451556]. system_clock works as expected [2017-02-02 12:22:14.434341].
If high_resolution_clock is important for time stamps, may be offset can be used?
uint64_t timestamp_now()
{
static auto hrc_offset = std::chrono::system_clock::now().time_since_epoch() - std::chrono::high_resolution_clock::now().time_since_epoch();
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now().time_since_epoch() + hrc_offset).count();
}
from nanolog.
Hi,
Can you give me a reference where it mentions steady_clock epoch is not Jan 1, 1970.
Thanks.
from nanolog.
Search steady_clock from google could result lots of discussions about system_clock, steady_clock, etc. Below are 2 of those references: cppreference,stackoverflow
from nanolog.
With libc++, high_resolution_clock epoch is the last boot time.
from nanolog.
uint64_t timestamp_now()
{
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch()).count();
}
void format_timestamp(std::ostream & os, uint64_t timestamp)
{
auto usecs = std::chrono::microseconds(timestamp);
auto secs = std::chrono::duration_cast<std::chrono::seconds> (usecs);
usecs -= secs;
std::time_t time_t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::time_point{ secs });
os << '[' << std::put_time(std::localtime(&time_t), "%Y-%m-%d %X");
os << "." << usecs.count() << ']';
}
[2018-05-01 21:17:45.272498][INFO][20072][c:\work\nanolog\main.cpp:main:20] Sample NanoLog: 0
[2018-05-01 21:17:45.272508][INFO][20072][c:\work\nanolog\main.cpp:main:20] Sample NanoLog: 1
[2018-05-01 21:17:45.272513][INFO][20072][c:\work\nanolog\main.cpp:main:20] Sample NanoLog: 2
[2018-05-01 21:17:45.272517][INFO][20072][c:\work\nanolog\main.cpp:main:20] Sample NanoLog: 3
[2018-05-01 21:17:45.272522][INFO][20072][c:\work\nanolog\main.cpp:main:20] Sample NanoLog: 4
from nanolog.
Related Issues (20)
- nanolog probably have a problem with char array HOT 1
- Scalability HOT 2
- gcc 4.8 build HOT 6
- Integration with a crash handling library HOT 2
- Remove full path from __FILE__ and only keep filename HOT 1
- Support for dll builds in Win HOT 3
- Can Nanolog suport for control file num,if the total size of log file is too large ,the old log can be delete auto
- Fix warning messages during compilation
- Local time instead of UTC ?
- Add an setting to append to the existing log file
- Console sink? HOT 2
- Conan package for NanoLog HOT 2
- Is this really a header only library HOT 2
- No performance comparison against PlatformLab/Nanolog HOT 1
- Unnecessary/unintentional flushing of the log
- No licence HOT 3
- Another NanoLog, what's the deference?
- Is this logger thread-safe
- Is it thread safe?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nanolog.