Skip to content

Commit

Permalink
dlt-system: add config to use uptime only (#630)
Browse files Browse the repository at this point in the history
Add a new JournalUseUptimeOnly config toggle.
With this toggle you can supress date and time
from the dlt-system payload, so we show only
the uptime of the system.
This toggle is for data protection purposes.
  • Loading branch information
danielweber2018 authored May 15, 2024
1 parent 35f599d commit 75f6c95
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
11 changes: 11 additions & 0 deletions doc/dlt-system.conf.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ Map journal log levels to DLT log levels.

Default: 1

## JournalUseOriginalTimestamp

Use the original timestamp (uptime when the event actually occured) as DLT timestamp.

Default: 1

## JournalUseUptimeOnly

Ignore the timestamp, show uptime (when the event actually occured) only in payload.

Default: 0

# FILETRANSFER OPTIONS

Expand Down
36 changes: 24 additions & 12 deletions src/system/dlt-system-journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,28 +286,40 @@ void get_journal_msg(sd_journal *j, DltSystemConfiguration *config)
else
snprintf(buffer_priority, DLT_SYSTEM_JOURNAL_BUFFER_SIZE, "prio_unknown:");

/* write log entry */
if (config->Journal.UseOriginalTimestamp == 0) {
if (config->Journal.UseUptimeOnly == 1) {
/* write log entry (uptime only, no timestamp) */
DLT_LOG(journalContext, loglevel,
DLT_STRING(timestamp.real),
DLT_STRING(timestamp.monotonic),
DLT_STRING(buffer_process),
DLT_STRING(buffer_priority),
DLT_STRING(buffer_message)
);

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,
/* write log entry (including timestamp) */
if (config->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)
);
}
}


if (journal_checkUserBufferForFreeSpace() == -1) {
/* buffer is nearly full */
/* wait 500ms for writing next entry */
Expand Down
4 changes: 4 additions & 0 deletions src/system/dlt-system-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,10 @@ int read_configuration_file(DltSystemConfiguration *config, char *file_name)
{
config->Journal.UseOriginalTimestamp = atoi(value);
}
else if (strcmp(token, "JournalUseUptimeOnly") == 0)
{
config->Journal.UseUptimeOnly = atoi(value);
}

/* File transfer */
else if (strcmp(token, "FiletransferEnable") == 0)
Expand Down
3 changes: 3 additions & 0 deletions src/system/dlt-system.conf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ JournalMapLogLevels = 1
# Use the original timestamp (uptime when the event actually occured) as DLT timestamp (Default: 1)
JournalUseOriginalTimestamp = 1

# Ignore the timestamp, show uptime (when the event actually occured) only in payload (Default: 0)
JournalUseUptimeOnly = 0

########################################################################
# Filetransfer Manager
########################################################################
Expand Down
1 change: 1 addition & 0 deletions src/system/dlt-system.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ typedef struct {
int Follow;
int MapLogLevels;
int UseOriginalTimestamp;
int UseUptimeOnly;
#ifdef DLT_SYSTEMD_WATCHDOG_ENFORCE_MSG_RX_ENABLE_DLT_SYSTEM
int MessageReceived;
#endif
Expand Down

0 comments on commit 75f6c95

Please sign in to comment.