SIAP: Secure Infrastructure Access Protocol 1.0.0.0a (A1)
A post-quantum secure user verification system and access control mechanism
logger.h File Reference

SIAP logging functions. More...

#include "siapcommon.h"

Go to the source code of this file.

Macros

#define SIAP_LOGGING_MESSAGE_MAX   256U
 Maximum length of a log message.

Functions

bool siap_logger_exists (void)
 Check if the SIAP log file exists.
void siap_logger_initialize (const char *path)
 Initialize the SIAP logger.
void siap_logger_print (void)
 Print the contents of the SIAP log file.
void siap_logger_read (char *output, size_t otplen)
 Read the SIAP log file into a provided buffer.
void siap_logger_reset (void)
 Reset the SIAP log.
size_t siap_logger_size (void)
 Get the current size of the SIAP log file.
bool siap_logger_write (const char *message)
 Write a message to the SIAP log file.
bool siap_logger_test (void)
 Run a manual test of the SIAP logger functions.

Detailed Description

SIAP logging functions.

This header file defines the internal logging functions for the Quantum Secure Messaging Protocol (SIAP). The logging subsystem provides basic functionality to create, manage, and inspect log files. These functions allow the SIAP system to record operational events, errors, and other informational messages which can be used for debugging and monitoring purposes.

The following constants are defined:

  • SIAP_LOGGING_MESSAGE_MAX: Maximum length allowed for a single log message.
  • SIAP_LOGGER_PATH: The default directory path for SIAP log files.
  • SIAP_LOGGER_FILE: The default filename for the SIAP log.
  • SIAP_LOGGER_HEAD: The header string for the log file, which typically includes version information.
Note
These functions and constants are internal and non-exportable.

Macro Definition Documentation

◆ SIAP_LOGGING_MESSAGE_MAX

#define SIAP_LOGGING_MESSAGE_MAX   256U

Maximum length of a log message.

This macro defines the maximum number of characters that a single log message may contain.

Function Documentation

◆ siap_logger_exists()

bool siap_logger_exists ( void )

Check if the SIAP log file exists.

This function checks for the existence of the SIAP log file in the configured logging directory.

Returns
Returns true if the log file exists; otherwise, false.

◆ siap_logger_initialize()

void siap_logger_initialize ( const char * path)

Initialize the SIAP logger.

This function initializes the logging subsystem by setting the log file path and creating the log file if it does not already exist. The default header (SIAP_LOGGER_HEAD) is written to the log file upon initialization.

Parameters
pathThe file path or directory where the log file should be created.

◆ siap_logger_print()

void siap_logger_print ( void )

Print the contents of the SIAP log file.

This function outputs the entire contents of the SIAP log file to the standard output or designated debug stream. It is useful for real-time monitoring and debugging purposes.

◆ siap_logger_read()

void siap_logger_read ( char * output,
size_t otplen )

Read the SIAP log file into a provided buffer.

This function reads the content of the SIAP log file and copies it into the specified output buffer. The caller must ensure that the output buffer is large enough to hold the log data, up to otplen bytes.

Parameters
outputA pointer to the buffer where the log content will be stored.
otplenThe size, in bytes, of the output buffer.

◆ siap_logger_reset()

void siap_logger_reset ( void )

Reset the SIAP log.

This function erases all the contents of the SIAP log file, effectively resetting it to an empty state. This operation is useful for clearing old log data before starting a new session.

◆ siap_logger_size()

size_t siap_logger_size ( void )

Get the current size of the SIAP log file.

This function returns the size of the log file in bytes. It can be used to monitor log growth and manage log rotation.

Returns
The size of the log file in bytes.

◆ siap_logger_test()

bool siap_logger_test ( void )

Run a manual test of the SIAP logger functions.

This function performs a series of tests on the SIAP logging subsystem. The test routine includes:

  • Initializing the logger with a test path.
  • Writing one or more test messages to the log.
  • Reading and printing the log content.
  • Resetting the log and verifying that it has been cleared.
  • Checking the reported log file size.

The function returns true if all logger operations work as expected.

Returns
Returns true if all logger tests succeed; otherwise, false.

◆ siap_logger_write()

bool siap_logger_write ( const char * message)

Write a message to the SIAP log file.

This function writes the specified log message to the SIAP log file. The message should be a null-terminated string, and its length should not exceed SIAP_LOGGING_MESSAGE_MAX characters.

Parameters
message[const] The log message to be written.
Returns
Returns true if the message was successfully written to the log file; otherwise, false.