add function comments

This commit is contained in:
Nayan
2025-05-08 21:31:43 -04:00
parent b52ce7dd0c
commit 51fe7e1c8d
5 changed files with 157 additions and 17 deletions

View File

@@ -12,10 +12,42 @@
#define LOG_WARN 2
#define LOG_ERROR 3
/**
* Sets the global log level for the logger.
*
* @param level The log level to set. Possible values are LOG_DEBUG, LOG_INFO,
* LOG_WARN, and LOG_ERROR. Messages below this level will not be logged.
*/
void set_log_level(int level);
void log_message(int level, const char* fmt, ...);
/**
* Opens the log file for appending log messages.
*
* @details
* This function attempts to open the log file specified by LOG_FILE_NAME
* in append mode. If the file cannot be opened, an error message is printed
* to stderr.
*/
void open_log_file();
void close_log_file();
/**
* Close the log file if it is open. This should be called when the program is
* about to exit to ensure that the log file is properly closed.
*
* @details
* If the log file is not open, this function does nothing.
*/
void close_log_file();
/**
* Logs a message with the given level and format string to the console and to
* the log file. If the level is less than the current log level, the message is
* not logged. The message is formatted according to fmt and varargs, and is
* prefixed with a timestamp and a string corresponding to the log level.
*
* @param level The log level to log the message at. Possible values are
* LOG_DEBUG, LOG_INFO, LOG_WARN, and LOG_ERROR.
* @param fmt The format string for the message to log
* @param ... The variadic arguments to format the string with
*/
void log_message(int level, const char* fmt, ...);