|
EzC
|
Prioritize and write to file your error and debugging messages. More...
#include <stdarg.h>#include <stdio.h>Go to the source code of this file.
Macros | |
| #define | ezc_log(type, message, ...) (ezc_log__(__FILE__, __LINE__, (type), (message), ##__VA_ARGS__)) |
| Add message to global log. More... | |
Typedefs | |
| typedef enum ezc_log_t | ezc_log_t |
| Log severity. More... | |
Enumerations | |
| enum | ezc_log_t { EZC_LOG_INFO = 0, EZC_LOG_WARN, EZC_LOG_ERROR, EZC_LOG_FATAL } |
| Log severity. More... | |
Functions | |
| void | ezc_log_echo (FILE *dest) |
| Set where logs are echoed to. More... | |
| char const * | ezc_log_get (ezc_log_t type) |
| Get most recent message of at least given severity. More... | |
| void | ezc_log_fwrite () |
| Write the global log to a file. More... | |
| void | ezc_log_clear () |
| Clear the global log. More... | |
Prioritize and write to file your error and debugging messages.
| #define ezc_log | ( | type, | |
| message, | |||
| ... | |||
| ) | (ezc_log__(__FILE__, __LINE__, (type), (message), ##__VA_ARGS__)) |
Add message to global log.
This macro accepts variadic arguments printf style. Messages are not echoed to stdout or stderr by default, but this can be changed via ezc_log_echo(FILE *).
| type | The message type enum. See ezc_log_t documentation for more info. |
| message | The message itself. Supports formatting just like printf. |
| ... | printf style variadic arguments. |
| enum ezc_log_t |
Log severity.
Helps prioritize your log messages.
| void ezc_log_clear | ( | ) |
Clear the global log.
Clears absolutely everything from info logs to fatal logs.
| void ezc_log_echo | ( | FILE * | dest | ) |
Set where logs are echoed to.
By default, logs are not echoed.
| dest | Echo destination. This can be stdout, stderr, or any file of your choosing. |
| void ezc_log_fwrite | ( | ) |
Write the global log to a file.
The file name is YYYY-MM-DD-HH-MM-SS.error, located in the directory the program was called from. If this file somehow already exists, it is overwritten. This function does not clear the log.
| char const* ezc_log_get | ( | ezc_log_t | type | ) |
Get most recent message of at least given severity.
For example, if the most recent item in the log is of type EZC_LOG_WARN, but ezc_log_get(EZC_LOG_ERROR) is called, it will skip over the warning item and keep stepping back through the log until an EZC_LOG_ERROR item is found.
| type | The returned log will be at least as severe as the log type specified by this argument. |
NULL if there have been no messages since the beginning of the program or the most recent ezc_log_clear(), or if no message of at least type priority was found.
1.8.15