liblogax
|
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
Go to the source code of this file.
Classes | |
struct | logax_logger_s |
Macros | |
#define | __LOGAX_FUNCTION__ "<unknown>" |
#define | LOGAX_NULL 0L |
#define | LOGAX_RESET_TERMINAL "\x1B[0m" |
#define | LOGAX_FOREGROUND_TRACE "\x1B[36m" |
#define | LOGAX_FOREGROUND_DEBUG "\x1B[32m" |
#define | LOGAX_FOREGROUND_INFO "\x1B[35m" |
#define | LOGAX_FOREGROUND_WARN "\x1B[33m" |
#define | LOGAX_FOREGROUND_ERROR "\x1B[31m" |
#define | LOGAX_FOREGROUND_FATAL "\x1B[31m" |
#define | LOGAX_RESET_TERMINAL_ATTR() fprintf(stream, "%s", LOGAX_RESET_TERMINAL) |
#define | LOGAX_MAX_CALLBACKS 5 |
#define | LOGAX_OPTION_QUITE LOGAX_OPTION_QUIET |
#define | GET_LEVEL_STRING(level) |
#define | logax_add_flag(flags, flag) flags |= flag; |
#define | logax_set_flag logax_add_flag |
#define | logax_remove_flag(flags, flag) flags &= ~flag; |
#define | logax_clear_flag logax_remove_flag |
#define | logax_set_formatter(logax_logger, new_formatter) |
#define | logax_set_quiet(logax_logger, make_quiet) |
#define | logax_set_quite logax_set_quiet |
#define | LOGAX_Iinitialized_HCONSOLE() |
#define | LOGAX_DELEGATE_FPRINT_STR(foreground, text) if (is_colored) { fprintf(stream, "%s%s%s", foreground, text, LOGAX_RESET_TERMINAL); } else { fprintf(stream, "%s", text); } |
#define | LOGAX_DELEGATE_FPRINT_SIZE_T(foreground, text) if (is_colored) { fprintf(stream, "%s%zu%s", foreground, text, LOGAX_RESET_TERMINAL); } else { fprintf(stream, "%zu", text); } |
#define | LOGAX_WRITE_COLOR_CODE(color) if (is_colored) { fprintf(stream, "%s", color); } |
#define | LOGAX_WRITE_LEVEL_COLOR__INTERNALL__(prefix_value, level, suffix_value) |
#define | logax_write_text_format_to_stream(stream, flags, fmt, ...) logax_write_text_format_to_stream__internal__(stream, flags, __FILE__, __LINE__, __LOGAX_FUNCTION__, fmt, __VA_ARGS__) |
#define | logax_write_key_value_format_to_stream(stream, flags, fmt, ...) logax_write_key_value_format_to_stream__internal__(stream, flags, __FILE__, __LINE__, __LOGAX_FUNCTION__, fmt, __VA_ARGS__) |
#define | LOGAX_INTERNAL_WRITE_JSON_STR(key, value) |
#define | LOGAX_INTERNAL_WRITE_JSON_SIZE_T(key, value) |
#define | logax_write_json_format_to_stream(stream, flags, fmt, ...) logax_write_json_format_to_stream__internal__(stream, flags, __FILE__, __LINE__, __LOGAX_FUNCTION__, fmt, __VA_ARGS__) |
#define | logax_logger_report_to_callback(logax_logger, level, fmt, ...) |
#define | logax_logger_trace(logax_logger, fmt, ...) |
#define | logax_logger_debug(logax_logger, fmt, ...) |
#define | logax_logger_info(logax_logger, fmt, ...) |
#define | logax_logger_warn(logax_logger, fmt, ...) |
#define | logax_logger_error(logax_logger, fmt, ...) |
#define | logax_logger_fatal(logax_logger, fmt, ...) |
Typedefs | |
typedef void(* | logax_callback) (const char *date, const char *time, const int level, const char *file, const size_t line_number, const char *function_name, const char *fmt,...) |
typedef struct logax_logger_s | LogaxLogger |
Enumerations | |
enum | LogaxOption { LOGAX_OPTION_QUIET = 1 << 1, LOGAX_OPTION_DATE = 1 << 2, LOGAX_OPTION_TIME = 1 << 3, LOGAX_OPTION_DATE_TIME = 1 << 4, LOGAX_OPTION_FILE_PATH = 1 << 5, LOGAX_OPTION_FILE_NAME_ONLY = 1 << 6, LOGAX_OPTION_LINE_NUMBER = 1 << 7, LOGAX_OPTION_COLORED = 1 << 8, LOGAX_OPTION_FUNCTION = 1 << 9, LOGAX_OPTION_ALL = 1 << 15 } |
enum | LogaxLevel { LOGAX_LEVEL_TRACE = 1 << 16, LOGAX_LEVEL_DEBUG = 1 << 17, LOGAX_LEVEL_INFO = 1 << 18, LOGAX_LEVEL_WARN = 1 << 19, LOGAX_LEVEL_ERROR = 1 << 20, LOGAX_LEVEL_FATAL = 1 << 21 } |
enum | LogaxFormatter { LOGAX_FORMATTER_TEXT = 1 << 25, LOGAX_FORMATTER_KEY_VALUE = 1 << 26, LOGAX_FORMATTER_JSON = 1 << 27 } |
#define __LOGAX_FUNCTION__ "<unknown>" |
The inline keyword to optimize the function. In C89 and C90 the inline keyword semantic is different from current C standard semantic hence for compilation targeting C89 or C99 the inline keyword is ommited.
#define GET_LEVEL_STRING | ( | level | ) |
Get the string name of the log level.
#define logax_add_flag | ( | flags, | |
flag | |||
) | flags |= flag; |
#define logax_clear_flag logax_remove_flag |
#define LOGAX_DELEGATE_FPRINT_SIZE_T | ( | foreground, | |
text | |||
) | if (is_colored) { fprintf(stream, "%s%zu%s", foreground, text, LOGAX_RESET_TERMINAL); } else { fprintf(stream, "%zu", text); } |
#define LOGAX_DELEGATE_FPRINT_STR | ( | foreground, | |
text | |||
) | if (is_colored) { fprintf(stream, "%s%s%s", foreground, text, LOGAX_RESET_TERMINAL); } else { fprintf(stream, "%s", text); } |
#define LOGAX_FOREGROUND_DEBUG "\x1B[32m" |
debug terminal foreground color - green
#define LOGAX_FOREGROUND_ERROR "\x1B[31m" |
error terminal foreground color - red
#define LOGAX_FOREGROUND_FATAL "\x1B[31m" |
fatal terminal foreground color - red
#define LOGAX_FOREGROUND_INFO "\x1B[35m" |
info terminal foreground color - magenta
#define LOGAX_FOREGROUND_TRACE "\x1B[36m" |
trace terminal foreground color - cyan
#define LOGAX_FOREGROUND_WARN "\x1B[33m" |
warn terminal foreground color - yellow
#define LOGAX_Iinitialized_HCONSOLE | ( | ) |
#define LOGAX_INTERNAL_WRITE_JSON_SIZE_T | ( | key, | |
value | |||
) |
#define LOGAX_INTERNAL_WRITE_JSON_STR | ( | key, | |
value | |||
) |
#define logax_logger_debug | ( | logax_logger, | |
fmt, | |||
... | |||
) |
#define logax_logger_error | ( | logax_logger, | |
fmt, | |||
... | |||
) |
#define logax_logger_fatal | ( | logax_logger, | |
fmt, | |||
... | |||
) |
#define logax_logger_info | ( | logax_logger, | |
fmt, | |||
... | |||
) |
#define logax_logger_report_to_callback | ( | logax_logger, | |
level, | |||
fmt, | |||
... | |||
) |
#define logax_logger_trace | ( | logax_logger, | |
fmt, | |||
... | |||
) |
#define logax_logger_warn | ( | logax_logger, | |
fmt, | |||
... | |||
) |
#define LOGAX_MAX_CALLBACKS 5 |
#define LOGAX_NULL 0L |
#define LOGAX_OPTION_QUITE LOGAX_OPTION_QUIET |
#define logax_remove_flag | ( | flags, | |
flag | |||
) | flags &= ~flag; |
#define LOGAX_RESET_TERMINAL "\x1B[0m" |
reset the terminal color
#define LOGAX_RESET_TERMINAL_ATTR | ( | ) | fprintf(stream, "%s", LOGAX_RESET_TERMINAL) |
reset the terminal color
#define logax_set_flag logax_add_flag |
#define logax_set_formatter | ( | logax_logger, | |
new_formatter | |||
) |
#define logax_set_quiet | ( | logax_logger, | |
make_quiet | |||
) |
#define logax_set_quite logax_set_quiet |
Alias for logax_set_quiet, for backward compatibility
#define LOGAX_WRITE_COLOR_CODE | ( | color | ) | if (is_colored) { fprintf(stream, "%s", color); } |
#define logax_write_json_format_to_stream | ( | stream, | |
flags, | |||
fmt, | |||
... | |||
) | logax_write_json_format_to_stream__internal__(stream, flags, __FILE__, __LINE__, __LOGAX_FUNCTION__, fmt, __VA_ARGS__) |
#define logax_write_key_value_format_to_stream | ( | stream, | |
flags, | |||
fmt, | |||
... | |||
) | logax_write_key_value_format_to_stream__internal__(stream, flags, __FILE__, __LINE__, __LOGAX_FUNCTION__, fmt, __VA_ARGS__) |
#define LOGAX_WRITE_LEVEL_COLOR__INTERNALL__ | ( | prefix_value, | |
level, | |||
suffix_value | |||
) |
#define logax_write_text_format_to_stream | ( | stream, | |
flags, | |||
fmt, | |||
... | |||
) | logax_write_text_format_to_stream__internal__(stream, flags, __FILE__, __LINE__, __LOGAX_FUNCTION__, fmt, __VA_ARGS__) |
typedef void(* logax_callback) (const char *date, const char *time, const int level, const char *file, const size_t line_number, const char *function_name, const char *fmt,...) |
This is the function signature of the callback, any function defined with same signature can be registered with the LogaxLogger as callback which will be invoked if a new logevent is sent.
typedef struct logax_logger_s LogaxLogger |
enum LogaxFormatter |
enum LogaxLevel |
The options to classify the log event by level
enum LogaxOption |
More bit location is reserved till 15 to accomodate new options without breaking backward compatibility