KLog API¶
API for the multi-platform Ham Radio logging protocol
-
int
klog_init_file
(klog_handle *handle)¶ Initialize KLog logging file.
This function will create a new log file and save the file pointer into handle->log_file.
- Return
- int 0 on success, -1 on error
- Parameters
handle
: Pointer to logging handle
-
void
klog_console
(unsigned level, const char *logger, const char *format, ...)¶ Add message to the console.
This function will add a message to the console if the passed message level is high enough
- Parameters
level
: Severity level of messagelogger
: Tag for messageformat
: Message to log
-
void
klog_file
(klog_handle *handle, unsigned level, const char *logger, const char *format, ...)¶ Add message to file.
This function will add a message to the specified logging file if the passed message level is high enough
- Parameters
handle
: Pointer to logging handlelevel
: Severity level of messagelogger
: Tag for messageformat
: Message to log
-
void
klog_cleanup
(klog_handle *handle)¶ Sync and close logging file.
- Parameters
handle
: Pointer to logging handle
-
KLOG_MAX_LINE
255¶
-
KLOG
(handle, level, logger, ...) klog_write(handle, level, logger, __VA_ARGS__)¶ Log message if level <= LOG_LEVEL.
-
KLOG_ERR
(handle, logger, ...) KLOG(handle, LOG_ERROR, logger, __VA_ARGS__)¶ Error logging define for convenience.
-
KLOG_WARN
(handle, logger, ...) KLOG(handle, LOG_WARNING, logger, __VA_ARGS__)¶ Warning logging define for convenience.
-
KLOG_TELEMETRY
(handle, logger, ...) KLOG(handle, LOG_TELEMETRY, logger, __VA_ARGS__)¶ Telemetry logging define for convenience.
-
KLOG_INFO
(handle, logger, ...) KLOG(handle, LOG_INFO, logger, __VA_ARGS__)¶ Info logging define for convenience.
-
KLOG_DEBUG
(handle, logger, ...) KLOG(handle, LOG_DEBUG, logger, __VA_ARGS__)¶ Debug logging define for convenience.
-
KLOG_SUFFIX_LEN
4¶ Length of suffix added to KLog files.
-
KLOG_PATH_LEN
255¶ Maximum KLog file path length.
-
KLOG_MAX_PATH
(KLOG_PATH_LEN - KLOG_SUFFIX_LEN - 1)¶ Maximum KLog file path length available to users.
-
KLOG_PART_SIZE_DEFAULT
(1024 * 512)¶ Default file partition size.
-
KLOG_MAX_PARTS_DEFAULT
4¶ Default partition count limit.
-
klog_write
(handle, level, logger, ...) do { \ if (level <= ((handle)->config.klog_console_level)) { \ klog_console(level, logger, __VA_ARGS__); \ } \ if (level <= ((handle)->config.klog_file_level) && ((handle)->config.klog_file_logging)) { \ klog_file(handle, level, logger, __VA_ARGS__); \ } \ } while (0)¶ KLog write macro.
If the specified level is greater than or equal to the current configured minimum logging level, calls logging function. Otherwise, ignores the input
- Parameters
handle
: Pointer to logging handlelevel
: Severity level of messagelogger
: Tag for message
-
struct
klog_config
¶ - #include <klog.h>
KLog configuration structure.
Public Members
-
char *
file_path
¶ Path to logging file.
-
uint8_t
file_path_len
¶ Character length of logging file path.
-
uint32_t
part_size
¶ Partition size.
-
uint8_t
max_parts
¶ Partition count limit.
-
uint8_t
klog_console_level
¶ Console logging level.
-
uint8_t
klog_file_level
¶ File logging level.
-
bool
klog_file_logging
¶ Specifies whether logging-to-file is enabled.
-
char *