Quantum Secure Tunneling Protocol 1.0.0.0a (A1)
A three-party quantum secure encrypted tunneling protocol
|
QSTP logging functions. More...
#include "common.h"
Go to the source code of this file.
Macros | |
#define | QSTP_LOGGING_MESSAGE_MAX 256 |
Maximum length of a log message. | |
Functions | |
bool | qstp_logger_exists (void) |
Test if the log file exists. | |
void | qstp_logger_initialize (const char *path) |
Initialize the logger. | |
void | qstp_logger_print (void) |
Print the log file. | |
void | qstp_logger_read (char *output, size_t otplen) |
Read the log file into a buffer. | |
void | qstp_logger_reset (void) |
Reset the logger. | |
size_t | qstp_logger_size (void) |
Get the size of the log file. | |
bool | qstp_logger_write (const char *message) |
Write a message to the log file. | |
bool | qstp_logger_test (void) |
Run a manual test of the logger functions. | |
QSTP logging functions.
This header defines the internal logging functions for the Quantum Secure Tunneling Protocol (QSTP). These functions provide a basic logging subsystem to record operational events, errors, and diagnostic messages during QSTP execution. The logging system is designed for debugging and monitoring purposes and includes functionality to initialize the log, write messages, read and print the log, reset (clear) the log, and retrieve the current log file size.
The logging subsystem uses several defined constants:
QSTP_LOGGING_MESSAGE_MAX:
Defines the maximum allowed length (in characters) for a single log message.QSTP_LOGGER_PATH:
The default directory path where the QSTP log file is stored.QSTP_LOGGER_FILE:
The default log filename.QSTP_LOGGER_HEAD:
The header string written to the log file at initialization, which typically includes version information.The logger also includes a built-in manual test (qstp_logger_test()
) that exercises all of the logging functions to ensure proper operation.
#define QSTP_LOGGING_MESSAGE_MAX 256 |
Maximum length of a log message.
This macro defines the maximum number of characters allowed for a single log message.
bool qstp_logger_exists | ( | void | ) |
Test if the log file exists.
This function checks whether the QSTP log file exists in the configured logging directory.
void qstp_logger_initialize | ( | const char * | path | ) |
Initialize the logger.
This function initializes the QSTP logging subsystem. It sets the log file path to the provided value and creates the log file if it does not already exist, writing the default header (QSTP_LOGGER_HEAD
) to the file.
path | A pointer to a null-terminated string specifying the log file path. |
void qstp_logger_print | ( | void | ) |
Print the log file.
This function outputs the contents of the QSTP log file to the standard output or a designated debug console. It is useful for real-time debugging and monitoring of log messages.
void qstp_logger_read | ( | char * | output, |
size_t | otplen ) |
Read the log file into a buffer.
This function reads the contents of the QSTP log file into the provided output array. The caller must ensure that the output buffer is large enough to hold the log contents.
output | A pointer to the buffer where the log contents will be stored. |
otplen | The size of the output buffer in bytes. |
void qstp_logger_reset | ( | void | ) |
Reset the logger.
This function erases all contents of the QSTP log file, effectively resetting the log. This is useful for clearing old log data before starting a new session or for troubleshooting.
size_t qstp_logger_size | ( | void | ) |
Get the size of the log file.
This function returns the current size (in bytes) of the QSTP log file.
bool qstp_logger_test | ( | void | ) |
Run a manual test of the logger functions.
This function performs a manual test of the QSTP logging subsystem. The test includes:
This test ensures that all logging operations (initialization, writing, reading, resetting, and size retrieval) function as expected.
bool qstp_logger_write | ( | const char * | message | ) |
Write a message to the log file.
This function appends the provided log message to the QSTP log file. The message should be a null-terminated string and must not exceed QSTP_LOGGING_MESSAGE_MAX
characters.
message | [const] A pointer to the log message string. |