Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Add GELF tags for high precision time
Browse files Browse the repository at this point in the history
_timestamp_ns gives time in nanosecond resolution for better time based sorting. Also add _log_id that can be used to detect dropped UDP packets
  • Loading branch information
spoonincode committed Apr 19, 2018
1 parent 07690ae commit b2be860
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libraries/fc/src/log/gelf_appender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ namespace fc
gelf_message["host"] = my->cfg.host;
gelf_message["short_message"] = format_string(message.get_format(), message.get_data());

gelf_message["timestamp"] = context.get_timestamp().time_since_epoch().count() / 1000000.;
const auto time_ns = context.get_timestamp().time_since_epoch().count();
gelf_message["timestamp"] = time_ns / 1000000.;
gelf_message["_timestamp_ns"] = time_ns;

static unsigned long gelf_log_counter;
gelf_message["_log_id"] = fc::to_string(++gelf_log_counter);

switch (context.get_log_level())
{
Expand Down

0 comments on commit b2be860

Please sign in to comment.