QSMP: Quantum Secure Messaging Protocol 1.3.0.0a (A3)
A quantum secure encrypted tunneling protocol
|
QSMP logging functions. More...
#include "common.h"
Go to the source code of this file.
Macros | |
#define | QSMP_LOGGING_MESSAGE_MAX 256 |
Maximum length of a log message. | |
Functions | |
bool | qsmp_logger_exists (void) |
Check if the QSMP log file exists. | |
void | qsmp_logger_initialize (const char *path) |
Initialize the QSMP logger. | |
void | qsmp_logger_print (void) |
Print the contents of the QSMP log file. | |
void | qsmp_logger_read (char *output, size_t otplen) |
Read the QSMP log file into a provided buffer. | |
void | qsmp_logger_reset (void) |
Reset the QSMP log. | |
size_t | qsmp_logger_size (void) |
Get the current size of the QSMP log file. | |
bool | qsmp_logger_write (const char *message) |
Write a message to the QSMP log file. | |
bool | qsmp_logger_test (void) |
Run a manual test of the QSMP logger functions. | |
QSMP logging functions.
This header file defines the internal logging functions for the Quantum Secure Messaging Protocol (QSMP). The logging subsystem provides basic functionality to create, manage, and inspect log files. These functions allow the QSMP system to record operational events, errors, and other informational messages which can be used for debugging and monitoring purposes.
The following constants are defined:
QSMP_LOGGING_MESSAGE_MAX:
Maximum length allowed for a single log message.QSMP_LOGGER_PATH:
The default directory path for QSMP log files.QSMP_LOGGER_FILE:
The default filename for the QSMP log.QSMP_LOGGER_HEAD:
The header string for the log file, which typically includes version information.#define QSMP_LOGGING_MESSAGE_MAX 256 |
Maximum length of a log message.
This macro defines the maximum number of characters that a single log message may contain.
bool qsmp_logger_exists | ( | void | ) |
Check if the QSMP log file exists.
This function checks for the existence of the QSMP log file in the configured logging directory.
void qsmp_logger_initialize | ( | const char * | path | ) |
Initialize the QSMP 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 (QSMP_LOGGER_HEAD
) is written to the log file upon initialization.
path | The file path or directory where the log file should be created. |
void qsmp_logger_print | ( | void | ) |
Print the contents of the QSMP log file.
This function outputs the entire contents of the QSMP log file to the standard output or designated debug stream. It is useful for real-time monitoring and debugging purposes.
void qsmp_logger_read | ( | char * | output, |
size_t | otplen ) |
Read the QSMP log file into a provided buffer.
This function reads the content of the QSMP 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.
output | A pointer to the buffer where the log content will be stored. |
otplen | The size, in bytes, of the output buffer. |
void qsmp_logger_reset | ( | void | ) |
Reset the QSMP log.
This function erases all the contents of the QSMP log file, effectively resetting it to an empty state. This operation is useful for clearing old log data before starting a new session.
size_t qsmp_logger_size | ( | void | ) |
Get the current size of the QSMP 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.
bool qsmp_logger_test | ( | void | ) |
Run a manual test of the QSMP logger functions.
This function performs a series of tests on the QSMP logging subsystem. The test routine includes:
The function returns true if all logger operations work as expected.
bool qsmp_logger_write | ( | const char * | message | ) |
Write a message to the QSMP log file.
This function writes the specified log message to the QSMP log file. The message should be a null-terminated string, and its length should not exceed QSMP_LOGGING_MESSAGE_MAX
characters.
message | [const] The log message to be written. |