diff options
author | Sebastian Unger <sunger@de.adit-jv.com> | 2019-06-13 13:41:12 +0200 |
---|---|---|
committer | Saya Sugiura <39760799+ssugiura@users.noreply.github.com> | 2019-09-13 08:48:03 +0900 |
commit | ecca21fd40be21164d664eb7d8a52ea1fdabfde0 (patch) | |
tree | fe63a7805235da22b67ff7f39d45f09af813db2e /src/system/dlt-system-journal.c | |
parent | 14ea971be7e808b9c5099c7f404ed3cf341873c4 (diff) | |
download | DLT-daemon-ecca21fd40be21164d664eb7d8a52ea1fdabfde0.tar.gz |
Add user custom timestamp interface
Two new macros are introduced so that users can use their customized
timestamps for DLT messages:
- DLT_LOG_TS(CONTEXT, LOGLEVEL, TS, ARGS ...)
- DLT_LOG_ID_TS(CONTEXT, LOGLEVEL, MSGID, TS, ARGS ...)
Detailed explanations can be found in dlt_for_developers.md.
Also a new option is added to dlt-system to use events' timestamps
from journald adapter.
Signed-off-by: Sebastian Unger <sunger@de.adit-jv.com>
Diffstat (limited to 'src/system/dlt-system-journal.c')
-rw-r--r-- | src/system/dlt-system-journal.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/system/dlt-system-journal.c b/src/system/dlt-system-journal.c index 5c10c50..2845406 100644 --- a/src/system/dlt-system-journal.c +++ b/src/system/dlt-system-journal.c @@ -202,6 +202,7 @@ void journal_thread(void *v_conf) sd_journal *j; char match[DLT_SYSTEM_JOURNAL_BOOT_ID_MAX_LENGTH] = "_BOOT_ID="; sd_id128_t boot_id; + uint32_t ts; char buffer_process[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 }, buffer_priority[DLT_SYSTEM_JOURNAL_BUFFER_SIZE] = { 0 }, @@ -345,13 +346,26 @@ void journal_thread(void *v_conf) snprintf(buffer_priority, DLT_SYSTEM_JOURNAL_BUFFER_SIZE, "prio_unknown:"); /* write log entry */ - DLT_LOG(journalContext, loglevel, - DLT_STRING(timestamp.real), - DLT_STRING(timestamp.monotonic), - DLT_STRING(buffer_process), - DLT_STRING(buffer_priority), - DLT_STRING(buffer_message) - ); + if (conf->Journal.UseOriginalTimestamp == 0) { + DLT_LOG(journalContext, loglevel, + DLT_STRING(timestamp.real), + DLT_STRING(timestamp.monotonic), + DLT_STRING(buffer_process), + DLT_STRING(buffer_priority), + DLT_STRING(buffer_message) + ); + + } + else { + /* since we are talking about points in time, I'd prefer truncating over arithmetic rounding */ + ts = (uint32_t)(atof(timestamp.monotonic) * 10000); + DLT_LOG_TS(journalContext, loglevel, ts, + DLT_STRING(timestamp.real), + DLT_STRING(buffer_process), + DLT_STRING(buffer_priority), + DLT_STRING(buffer_message) + ); + } } else { r = sd_journal_wait(j, 1000000); |