PebbleOS
Loading...
Searching...
No Matches
Macros | Functions
logging.h File Reference
#include <console/dbgserial.h>
#include <system/die.h>
#include <system/reboot_reason.h>
#include <system/status_codes.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <pbl/kernel/compiler.h>

Macros

#define SPLIT_64_BIT_ARG(x)   (uint32_t)((x >> 32) & 0xFFFFFFFF), (uint32_t)(x & 0xFFFFFFFF)
 Expand a 64-bit value into two 32-bit arguments, high word first.
 
#define LOG_BUFFER_LENGTH   128
 Size of the buffer a log message is formatted into, header included.
 
#define LOGGING_MIN_STACK_FOR_SPRINTF   240
 Minimum free stack, in bytes, to format a message; below it the message is replaced.
 
#define LOGGING_STACK_FULL_MSG   ((const char *)" [STK FULL]")
 Message logged instead when the stack is too full to format it.
 
#define LOG_LEVEL_ALWAYS   0
 Level of messages that are never filtered.
 
#define LOG_LEVEL_ERROR   1
 Error level.
 
#define LOG_LEVEL_WARNING   50
 Warning level.
 
#define LOG_LEVEL_INFO   100
 Info level.
 
#define LOG_LEVEL_DEBUG   200
 Debug level.
 
#define LOG_LEVEL_DEBUG_VERBOSE   255
 Verbose debug level.
 
#define LOG_LEVEL_OFF   (-1)
 Module level that disables every message of the module.
 
#define DEFAULT_LOG_LEVEL   LOG_LEVEL_DEBUG
 Compile-time level of files without a log module, from CONFIG_DEFAULT_LOG_LEVEL.
 
#define FLASH_LOG_LEVEL   LOG_LEVEL_INFO
 Highest level written to the flash log, from the CONFIG_FLASH_LOG_LEVEL_ choice.
 
#define STRINGIFY_NX(a)   #a
 Turn the argument into a string literal without expanding it.
 
#define STRINGIFY(a)   STRINGIFY_NX(a)
 Turn the expansion of the argument into a string literal.
 
#define STATUS_STRING(s)   STRINGIFY(s)
 Turn the expansion of a status code into a string literal.
 
#define PBL_LOG_MODULE_DEFINE(name, level)   PBL_UNUSED static const int16_t _pbl_log_module_level = 0
 Put the current file in a log module, defining the module.
 
#define PBL_LOG_MODULE_DECLARE(name, level)   PBL_LOG_MODULE_DEFINE(name, level)
 Put the current file in a log module defined in another file.
 
#define PBL_LOG_MODULE_LEVEL_GET(name)
 Get the runtime level of a module built with CONFIG_<module>_LOG_LEVEL_RUNTIME.
 
#define PBL_LOG_MODULE_LEVEL_SET(name, level)
 Set the runtime level of a module built with CONFIG_<module>_LOG_LEVEL_RUNTIME.
 
#define PBL_SHOULD_LOG(level)
 Check whether the current file logs messages of a level.
 
#define PBL_LOG_COLOR(level, color, fmt, ...)
 Log a message with an explicit level and color, possibly queued.
 
#define PBL_LOG_COLOR_SYNC(level, color, fmt, ...)
 Log a message with an explicit level and color, sent before returning.
 
#define PBL_LOG_ALWAYS(fmt, ...)    PBL_LOG_COLOR(LOG_LEVEL_ALWAYS, LOG_COLOR_FOR_ALWAYS, fmt, ##__VA_ARGS__)
 Log a message that is never filtered, possibly queued.
 
#define PBL_LOG_ERR(fmt, ...)    PBL_LOG_COLOR(LOG_LEVEL_ERROR, LOG_COLOR_FOR_ERROR, fmt, ##__VA_ARGS__)
 Log an error, possibly queued.
 
#define PBL_LOG_WRN(fmt, ...)    PBL_LOG_COLOR(LOG_LEVEL_WARNING, LOG_COLOR_FOR_WARNING, fmt, ##__VA_ARGS__)
 Log a warning, possibly queued.
 
#define PBL_LOG_INFO(fmt, ...)   PBL_LOG_COLOR(LOG_LEVEL_INFO, LOG_COLOR_FOR_INFO, fmt, ##__VA_ARGS__)
 Log an attention-worthy event, possibly queued.
 
#define PBL_LOG_DBG(fmt, ...)    PBL_LOG_COLOR(LOG_LEVEL_DEBUG, LOG_COLOR_FOR_DEBUG, fmt, ##__VA_ARGS__)
 Log a routine debug message, possibly queued.
 
#define PBL_LOG_VERBOSE(fmt, ...)    PBL_LOG_COLOR(LOG_LEVEL_DEBUG_VERBOSE, LOG_COLOR_FOR_VERBOSE, fmt, ##__VA_ARGS__)
 Log a verbose debug message, possibly queued.
 
#define PBL_LOG_SYNC_ALWAYS(fmt, ...)    PBL_LOG_COLOR_SYNC(LOG_LEVEL_ALWAYS, LOG_COLOR_FOR_ALWAYS, fmt, ##__VA_ARGS__)
 Log a message that is never filtered, sent before returning.
 
#define PBL_LOG_SYNC_ERR(fmt, ...)    PBL_LOG_COLOR_SYNC(LOG_LEVEL_ERROR, LOG_COLOR_FOR_ERROR, fmt, ##__VA_ARGS__)
 Log an error, sent before returning.
 
#define PBL_LOG_SYNC_WRN(fmt, ...)    PBL_LOG_COLOR_SYNC(LOG_LEVEL_WARNING, LOG_COLOR_FOR_WARNING, fmt, ##__VA_ARGS__)
 Log a warning, sent before returning.
 
#define PBL_LOG_SYNC_INFO(fmt, ...)    PBL_LOG_COLOR_SYNC(LOG_LEVEL_INFO, LOG_COLOR_FOR_INFO, fmt, ##__VA_ARGS__)
 Log an attention-worthy event, sent before returning.
 
#define PBL_LOG_SYNC_DBG(fmt, ...)    PBL_LOG_COLOR_SYNC(LOG_LEVEL_DEBUG, LOG_COLOR_FOR_DEBUG, fmt, ##__VA_ARGS__)
 Log a routine debug message, sent before returning.
 
#define PBL_LOG_SYNC_VERBOSE(fmt, ...)    PBL_LOG_COLOR_SYNC(LOG_LEVEL_DEBUG_VERBOSE, LOG_COLOR_FOR_VERBOSE, fmt, ##__VA_ARGS__)
 Log a verbose debug message, sent before returning.
 
#define RETURN_STATUS(st)   return (st)
 Return a status code, logging a warning if it is a failure.
 
#define RETURN_STATUS_UP(st)   return ((st) == E_INVALID_ARGUMENT ? E_INTERNAL : (st))
 Return a status code to the caller, turning E_INVALID_ARGUMENT into E_INTERNAL.
 
Log colors

Color names stored with hashed messages, used by the host console.

#define LOG_COLOR_BLACK   "BLACK"
 Black, hardly readable.
 
#define LOG_COLOR_RED   "RED"
 Red.
 
#define LOG_COLOR_GREEN   "GREEN"
 Green.
 
#define LOG_COLOR_YELLOW   "YELLOW"
 Yellow.
 
#define LOG_COLOR_BLUE   "BLUE"
 Blue.
 
#define LOG_COLOR_MAGENTA   "MAGENTA"
 Magenta.
 
#define LOG_COLOR_CYAN   "CYAN"
 Cyan.
 
#define LOG_COLOR_GREY   "GREY"
 Grey.
 
#define LOG_COLOR_LIGHT_GREY   "LIGHT_GREY"
 Light grey, reserved for bold like the other light colors.
 
#define LOG_COLOR_LIGHT_RED   "LIGHT_RED"
 Light red.
 
#define LOG_COLOR_LIGHT_GREEN   "LIGHT_GREEN"
 Light green.
 
#define LOG_COLOR_LIGHT_YELLOW   "LIGHT_YELLOW"
 Light yellow.
 
#define LOG_COLOR_LIGHT_BLUE   "LIGHT_BLUE"
 Light blue.
 
#define LOG_COLOR_LIGHT_MAGENTA   "LIGHT_MAGENTA"
 Light magenta.
 
#define LOG_COLOR_LIGHT_CYAN   "LIGHT_CYAN"
 Light cyan.
 
#define LOG_COLOR_WHITE   "WHITE"
 White.
 
#define LOG_COLOR_FOR_ALWAYS   LOG_COLOR_BLUE
 Color of LOG_LEVEL_ALWAYS messages.
 
#define LOG_COLOR_FOR_ERROR   LOG_COLOR_RED
 Color of LOG_LEVEL_ERROR messages.
 
#define LOG_COLOR_FOR_WARNING   LOG_COLOR_YELLOW
 Color of LOG_LEVEL_WARNING messages.
 
#define LOG_COLOR_FOR_INFO   LOG_COLOR_GREEN
 Color of LOG_LEVEL_INFO messages.
 
#define LOG_COLOR_FOR_DEBUG   LOG_COLOR_GREY
 Color of LOG_LEVEL_DEBUG messages.
 
#define LOG_COLOR_FOR_VERBOSE   LOG_COLOR_GREY
 Color of LOG_LEVEL_DEBUG_VERBOSE messages.
 

Functions

void pbl_log_hashed_async (const uint32_t packed_loghash,...)
 Log a hashed message, possibly queued.
 
void pbl_log_hashed_sync (const uint32_t packed_loghash,...)
 Log a hashed message, sent before returning.
 
void pbl_log_hashed_filtered_async (const uint32_t packed_loghash,...)
 pbl_log_hashed_async() for modules with a runtime level, bypassing the sink filters.
 
void pbl_log_hashed_filtered_sync (const uint32_t packed_loghash,...)
 pbl_log_hashed_sync() for modules with a runtime level, bypassing the sink filters.
 
void pbl_log_hashed_core (const uint32_t core_number, const uint32_t packed_loghash,...)
 Log a hashed message from another core, possibly queued.
 
void pbl_log_hashed_vargs (const bool async, const uint32_t core_number, const uint32_t packed_loghash, va_list fmt_args)
 Log a hashed message from another core, with a va_list.
 
void pbl_log_vargs (uint8_t log_level, const char *src_filename, int src_line_number, const char *fmt, va_list args)
 Log a message with a va_list, possibly queued.
 
void pbl_log (uint8_t log_level, const char *src_filename, int src_line_number, const char *fmt,...)
 Log a message, possibly queued.
 
void pbl_log_sync (uint8_t log_level, const char *src_filename, int src_line_number, const char *fmt,...)
 Log a message, sent before returning.
 
void pbl_log_filtered (uint8_t log_level, const char *src_filename, int src_line_number, const char *fmt,...)
 pbl_log() for modules with a runtime level, bypassing the sink filters.
 
void pbl_log_filtered_sync (uint8_t log_level, const char *src_filename, int src_line_number, const char *fmt,...)
 pbl_log_sync() for modules with a runtime level, bypassing the sink filters.
 
int pbl_log_binary_format (char *buffer, int buffer_len, const uint8_t log_level, const char *src_filename_path, int src_line_number, const char *fmt, va_list args)
 Format a message as a binary log record.
 
int pbl_log_get_bin_format (char *buffer, int buffer_len, const uint8_t log_level, const char *src_filename_path, int src_line_number, const char *fmt,...)
 pbl_log_binary_format() with variadic arguments.