Skip to content

Commit

Permalink
Changes following review
Browse files Browse the repository at this point in the history
Signed-off-by: Shamser Ahmed <shamser.ahmed@lexisnexis.com>
  • Loading branch information
shamser committed Dec 23, 2024
1 parent 2fbd9e8 commit 0ef1d4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions dali/base/sysinfologger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define ATTR_HIDDEN "@hidden"
#define ATTR_SOURCE "@source"

#define NON_SYSLOGMSG_MASK 0x8000000000
static constexpr unsigned __int64 nonSysInfoLogMsgMask = 0x80000000;

static void extractDate(timestamp_type ts, unsigned & year, unsigned & month, unsigned & day)
{
Expand All @@ -45,7 +45,11 @@ static void extractDate(timestamp_type ts, unsigned & year, unsigned & month, un

unsigned __int64 makeMessageId(unsigned year, unsigned month, unsigned day, unsigned seqN, bool nonSysInfoLogMsg)
{
return (nonSysInfoLogMsg?NON_SYSLOGMSG_MASK:0) | seqN<<21 | year<<9 | month<<5 | day;
// bits 0-4 = day, bits 5-8 = month, bits 9-23 = year
// bit 24-30 unused
// bit 31 = (flag) unset means SysInfoLogger managed message, set means message managed elsewhere
// bits 32-63 = sequence number
return seqN<<32 | (nonSysInfoLogMsg?nonSysInfoLogMsgMask:0) | year<<9 | month<<5 | day;
}

unsigned __int64 makeMessageId(unsigned __int64 ts, unsigned seqN, bool nonSysInfoLogMsg)
Expand All @@ -59,9 +63,9 @@ static bool decodeMessageId(unsigned __int64 msgId, unsigned & year, unsigned &
{
day = msgId & 0x1F;
month = (msgId>>5) & 0x0F;
year = (msgId>>9) & 0xFFF;
seqn = (msgId>>21);
return msgId & NON_SYSLOGMSG_MASK;
year = (msgId>>9) & 0x3FFF;
seqn = msgId>>32;
return msgId & nonSysInfoLogMsgMask;
}

class CSysInfoLoggerMsg : implements ISysInfoLoggerMsg
Expand Down
2 changes: 1 addition & 1 deletion dali/base/sysinfologger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ SYSINFO_API bool deleteLogSysInfoMsg(unsigned __int64 msgId, const char *source=
SYSINFO_API unsigned deleteOlderThanLogSysInfoMsg(bool visibleOnly, bool hiddenOnly, unsigned year, unsigned month, unsigned day, const char *source=nullptr);

/* makeMessageId - Create a message id from date, sequence number and nonSysInfoLogMsg flag to uniquely identify a message
- nonSysInfoLogMsg flag is used to identify whether or not the message managed by SysInfoLogger */
- nonSysInfoLogMsg flag is used to identify whether or not the message is managed by SysInfoLogger */
SYSINFO_API unsigned __int64 makeMessageId(unsigned __int64 ts, unsigned seqN, bool nonSysInfoLogMsg=false);
SYSINFO_API unsigned __int64 makeMessageId(unsigned year, unsigned month, unsigned day, unsigned seqN, bool nonSysInfoLogMsg=false);
#endif

0 comments on commit 0ef1d4c

Please sign in to comment.