Zero Trust IoT library
Loading...
Searching...
No Matches
ZtLogger Class Reference

Logging utility for Zero Trust simulation modules in NS-3. More...

#include <zt-logger.h>

Collaboration diagram for ZtLogger:

Static Public Member Functions

static void EnableTimestamps (bool enable)
 Enables or disables timestamp logging.
 
static void Log (const std::string &tag, const std::string &message)
 Logs a general message with a specified tag.
 
static void LogCertIssued (uint32_t nodeId, const std::string &role, time_t expiry)
 Logs a certificate issuance event.
 
static void LogCertValidationResult (uint32_t nodeId, bool valid)
 Logs the result of certificate validation.
 
static void LogCertRevoked (uint32_t nodeId)
 Logs a certificate revocation event.
 
static void LogCertRejected (const std::string &reason)
 Logs a rejected certificate attempt with a reason.
 
static void LogEncryption (const std::string &payload, const std::string &ivHex)
 Logs an encryption event with payload and IV.
 
static void LogDecryption (const std::string &payload)
 Logs a successful decryption event.
 
static void LogDecryptionFailure ()
 Logs a decryption failure event.
 

Static Private Attributes

static bool timestampsEnabled = true
 Flag to indicate if timestamps are enabled in logs.
 

Detailed Description

Logging utility for Zero Trust simulation modules in NS-3.

Provides logging functions for general events, certificate-related events, and encryption/decryption actions. Supports optional timestamps.

Definition at line 15 of file zt-logger.h.

Member Function Documentation

◆ EnableTimestamps()

void ZtLogger::EnableTimestamps ( bool  enable)
static

Enables or disables timestamp logging.

Enables or disables timestamps in log messages.

Parameters
enableTrue to include timestamps in logs, false to omit them.
enableIf true, timestamps will be included in logs.

Definition at line 16 of file zt-logger.cc.

16 {
17 timestampsEnabled = enable;
18}
static bool timestampsEnabled
Flag to indicate if timestamps are enabled in logs.
Definition zt-logger.h:76
Here is the caller graph for this function:

◆ Log()

void ZtLogger::Log ( const std::string &  tag,
const std::string &  message 
)
static

Logs a general message with a specified tag.

Logs a message with a given tag and optional timestamp.

Parameters
tagContext label (e.g., "INFO", "ERROR").
messageThe message content.
tagA short string indicating the type or source of the message.
messageThe actual log message content.

Definition at line 25 of file zt-logger.cc.

25 {
26 std::ostringstream output;
27
29 std::time_t now = std::time(nullptr);
30 std::tm *lt = std::localtime(&now);
31 output << "[" << std::put_time(lt, "%H:%M:%S") << "] ";
32 }
33
34 output << "[" << tag << "] " << message;
35 NS_LOG_UNCOND(output.str());
36}
Here is the caller graph for this function:

◆ LogCertIssued()

void ZtLogger::LogCertIssued ( uint32_t  nodeId,
const std::string &  role,
time_t  expiry 
)
static

Logs a certificate issuance event.

Logs the issuance of a certificate.

Parameters
nodeIdID of the node receiving the certificate.
roleAssigned role for the node.
expiryExpiry time of the certificate.
nodeIdThe ID of the node receiving the certificate.
roleThe assigned role in the certificate.
expiryThe expiration time of the certificate.

Definition at line 46 of file zt-logger.cc.

46 {
47 std::ostringstream msg;
48 msg << "Issued certificate to Node " << nodeId << " | Role: " << role
49 << " | Expiry: " << expiry;
50 Log("ZT-CERT", msg.str());
51}
static void Log(const std::string &tag, const std::string &message)
Logs a general message with a specified tag.
Definition zt-logger.cc:25
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogCertRejected()

void ZtLogger::LogCertRejected ( const std::string &  reason)
static

Logs a rejected certificate attempt with a reason.

Logs a rejection reason for a certificate.

Parameters
reasonDescription of the rejection cause.
reasonThe explanation for why the certificate was rejected.

Definition at line 75 of file zt-logger.cc.

75 {
76 Log("ZT-CERT", "Certificate rejected: " + reason);
77}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogCertRevoked()

void ZtLogger::LogCertRevoked ( uint32_t  nodeId)
static

Logs a certificate revocation event.

Logs the revocation of a certificate.

Parameters
nodeIdID of the node whose certificate was revoked.
nodeIdThe ID of the node whose certificate was revoked.

Definition at line 67 of file zt-logger.cc.

67 {
68 Log("ZT-CERT", "Node " + std::to_string(nodeId) + " certificate revoked");
69}
Here is the call graph for this function:

◆ LogCertValidationResult()

void ZtLogger::LogCertValidationResult ( uint32_t  nodeId,
bool  valid 
)
static

Logs the result of certificate validation.

Logs the result of a certificate validation attempt.

Parameters
nodeIdID of the node whose certificate was validated.
validTrue if the certificate is valid, false otherwise.
nodeIdThe node whose certificate was validated.
validTrue if the certificate is valid, false otherwise.

Definition at line 58 of file zt-logger.cc.

58 {
59 Log("ZT-CERT", "Validation for Node " + std::to_string(nodeId) +
60 (valid ? ": VALID" : ": INVALID"));
61}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogDecryption()

void ZtLogger::LogDecryption ( const std::string &  payload)
static

Logs a successful decryption event.

Logs a successful decryption result.

Parameters
payloadThe decrypted plaintext data.
payloadThe decrypted plaintext.

Definition at line 94 of file zt-logger.cc.

94 {
95 Log("ZT-DEC", "Decrypted Payload: " + payload);
96}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogDecryptionFailure()

void ZtLogger::LogDecryptionFailure ( )
static

Logs a decryption failure event.

Logs a failure during decryption due to invalid session or corrupted data.

Definition at line 101 of file zt-logger.cc.

101 {
102 Log("ZT-DEC", "Decryption failed: Invalid session or corrupt data");
103}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ LogEncryption()

void ZtLogger::LogEncryption ( const std::string &  payload,
const std::string &  ivHex 
)
static

Logs an encryption event with payload and IV.

Logs encryption activity with IV and encrypted data.

Parameters
payloadThe encrypted data.
ivHexInitialization Vector in hex string format.
payloadThe encrypted data in hex or readable format.
ivHexThe IV used during encryption, in hex format.

Definition at line 86 of file zt-logger.cc.

86 {
87 Log("ZT-ENC", "Payload encrypted | IV: " + ivHex + " | Data: " + payload);
88}
Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ timestampsEnabled

bool ZtLogger::timestampsEnabled = true
staticprivate

Flag to indicate if timestamps are enabled in logs.

Static flag to control timestamp display.

Definition at line 76 of file zt-logger.h.


The documentation for this class was generated from the following files: