logο
Header: udo/log.h
Table of contents (click to go)ο
Macrosο
Enumsο
Unionsο
Structsο
Functionsο
API Documentationο
udo_log_level_typeο
-
enum udo_log_level_typeο
- Sets which messages of a given type to print and is used tohelp determine which ANSI Escape Codes to utilize.
- Log level options used by
-
enumerator UDO_LOG_NONEο
-
enumerator UDO_LOG_SUCCESSο
-
enumerator UDO_LOG_DANGERο
-
enumerator UDO_LOG_INFOο
-
enumerator UDO_LOG_WARNINGο
-
enumerator UDO_LOG_RESETο
-
enumerator UDO_LOG_ALLο
UDO_LOG_NONE- Value set to
0x00000000Term color UDO_LOG_SUCCESS- Value set to
0x00000001Green UDO_LOG_DANGER- Value set to
0x00000002Red UDO_LOG_INFO- Value set to
0x00000004Light purple UDO_LOG_WARNING- Value set to
0x00000008Yellow UDO_LOG_RESET- Value set to
0x00000010Term color UDO_LOG_ALL- Value set to
0xFFFFFFFFTerm color
udo_log_set_levelο
-
void udo_log_set_level(enum udo_log_level_type level);ο
Sets which type of messages that are allowed
to be printed to an open file.
Default is set to
UDO_LOG_NONE.
Param
Decription
level
32-bit integer representing the typeof log to print to an open file. Eachlog type has a different color.
udo_log_set_write_fdο
-
void udo_log_set_write_fd(const int fd);ο
Sets the internal global write file descriptor
to caller define file descriptor.
Default is set to
STDOUT_FILENO.
Param
Decription
fd
File descriptor to an open file.
udo_log_remove_colorsο
-
void udo_log_remove_colors(void);ο
Sets the internal global ansi color
storage array to remove the ansi colors
and replace with β[LOG_TYPE] β.
udo_log_reset_colorsο
-
void udo_log_reset_colors(void);ο
Sets the internal global ansi color
storage array to itβs original values.
udo_log_error_typeο
-
enum udo_log_error_typeο
Enum with enumerators defining an error type.
- Log error types used by
UDO_LOG_ERR_UNCOMMON Value set to0x1000Errors that canβt be given a commonerror string are given this error code.Caller would then need to set buffer themselves.UDO_LOG_ERR_INCORRECT_DATA Value set to0x1001Code for incorrect data passed in function arguments.
udo_log_error_structο
-
struct udo_log_error_structο
Structure used to store and acquire
error string and code for multiple
struct contextβs.
udo_log_get_errorο
-
const char *udo_log_get_error(const void *context);ο
Returns a string with the error defined given
caller provided a context with first members
of the context being a
struct udo_log_error_struct.
Param
Decription
context
- Returns:
on success: Passed context error stringon failure:NULL
udo_log_get_error_codeο
-
uint32_t udo_log_get_error_code(const void *context);ο
Returns unsigned integer with the error code
given caller provided a context with first members
of the context being a
struct udo_log_error_struct.
Param
Decription
context
- Returns:
on success: Passed context error code or errnoon failure:UINT32_MAX
udo_log_set_error_structο
-
void udo_log_set_error_struct(void *context, const uint32_t code, const char *fmt, ...);ο
Sets
struct udo_log_error_struct members value.
Param
Decription
context
code
Error code to set for acontextfmt
Format of the log passed to va_args.β¦
Variable list arguments.
udo_log_timeο
-
void udo_log_time(enum udo_log_level_type type, const char *fmt, ...);ο
Provides applications/library way to write to an open file
with a time stamp and ansi color codes to colorize
different message.
Param
Decription
type
The type of color to use with log.fmt
Format of the log passed to va_args.β¦
Variable list arguments.
udo_log_notimeο
-
void udo_log_notime(enum udo_log_level_type type, const char *fmt, ...);ο
Provides applications/library way to write to an open file
without time stamp with ansi color codes to colorize
different message.
Param
Decription
type
The type of color to use with log.fmt
Format of the log passed to va_args.β¦
Variable list arguments.
udo_logο
-
udo_log(log_type, fmt, ...)ο
Log format
timestamp [file:line] message
Default prints to
stdout using ansi color codes to color text.Caller may change the open file in which logs are printed to via
a call to
udo_log_set_write_fd().#define udo_log(log_type, fmt, ...) \ udo_log_time(log_type, "[%s:%d] " fmt, __FILE_NAME__, __LINE__, ##__VA_ARGS__)
udo_log_successο
-
udo_log_success(fmt, ...)ο
Log format
timestamp [file:line] message
Prints to
stdout with ansi color codes the color GREEN.Caller may change the open file in which logs are printed to via
a call to
udo_log_set_write_fd().#define udo_log_success(fmt, ...) \ udo_log_time(UDO_LOG_SUCCESS, "[%s:%d] " fmt, __FILE_NAME__, __LINE__, ##__VA_ARGS__)
udo_log_infoο
-
udo_log_info(fmt, ...)ο
Log format
timestamp [file:line] message
Prints to
stdout with ansi color codes the color BLUE.Caller may change the open file in which logs are printed to via
a call to
udo_log_set_write_fd().#define udo_log_info(fmt, ...) \ udo_log_time(UDO_LOG_INFO, "[%s:%d] " fmt, __FILE_NAME__, __LINE__, ##__VA_ARGS__)
udo_log_warningο
-
udo_log_warning(fmt, ...)ο
Log format
timestamp [file:line] message
Prints to
stdout with ansi color codes the color YELLOW.Caller may change the open file in which logs are printed to via
a call to
udo_log_set_write_fd().#define udo_log_warning(fmt, ...) \ udo_log_time(UDO_LOG_WARNING, "[%s:%d] " fmt, __FILE_NAME__, __LINE__, ##__VA_ARGS__)
udo_log_errorο
-
udo_log_error(fmt, ...)ο
Log format
timestamp [file:line] message
Prints to
stderr with ansi color codes the color RED.Caller may change the open file in which logs are printed to via
a call to
udo_log_set_write_fd().#define udo_log_error(fmt, ...) \ udo_log_time(UDO_LOG_ERROR, "[%s:%d] " fmt, __FILE_NAME__, __LINE__, ##__VA_ARGS__)
udo_log_printο
-
udo_log_print(log_type, fmt, ...)ο
Log format
NONE
Default prints to
stdout using ansi color codes to color text.Caller may change the open file in which logs are printed to via
a call to
udo_log_set_write_fd().#define udo_log_print(log_type, fmt, ...) \ udo_log_notime(log_type, fmt, ##__VA_ARGS__)
udo_log_set_errorο
-
udo_log_set_error(ptr, code, fmt, ...)ο
#define udo_log_set_error(ptr, code, fmt, ...) \ udo_log_set_error_struct(ptr, code, "[%s:%d] " fmt, __FILE_NAME__, __LINE__, ##__VA_ARGS__)