PebbleOS v4.44.0-79-gafcb109f5
Loading...
Searching...
No Matches
Backends

Outputs of log messages. More...

Data Structures

struct  pbl_log_msg
 Log message. More...
 
struct  pbl_log_backend_api
 Backend operations. More...
 
struct  pbl_log_backend_state
 Runtime state of a backend. More...
 
struct  pbl_log_backend
 Backend. More...
 

Macros

#define PBL_LOG_MSG_ASYNC   (1U << 0)
 The message may be written after pbl_log_backend_api::process returns.
 
#define PBL_LOG_MSG_FAULT   (1U << 1)
 The message comes from a fault handler, where OS services are unavailable.
 
#define PBL_LOG_BACKEND_DEFINE(_name, _api, _level, _autostart)
 Define a backend.
 
#define PBL_LOG_BACKEND_GET(_name)
 Get a backend defined with PBL_LOG_BACKEND_DEFINE.
 

Functions

void pbl_log_backend_enable (const struct pbl_log_backend *backend)
 Start passing messages to backend.
 
void pbl_log_backend_disable (const struct pbl_log_backend *backend)
 Stop passing messages to backend.
 
bool pbl_log_backend_is_enabled (const struct pbl_log_backend *backend)
 Whether messages are passed to backend.
 
void pbl_log_backend_set_level (const struct pbl_log_backend *backend, int level)
 Set the highest LOG_LEVEL_* level written by backend.
 
const struct pbl_log_backend * pbl_log_backend_get_by_name (const char *name)
 Find a backend by name.
 
void pbl_log_init (void)
 Initialize the backends.
 
void pbl_log_panic (void)
 Have every backend write out its pending messages, the system is about to stop.
 

Detailed Description

Outputs of log messages.

A backend is defined with PBL_LOG_BACKEND_DEFINE and receives every message at or below its level through pbl_log_backend_api::process, in the context of the caller. The logging core only knows backends through this interface.


Data Structure Documentation

◆ pbl_log_msg

struct pbl_log_msg

Log message.

Data Fields
const uint8_t * app_uuid UUID of the app that logged the message, or NULL for system messages.
const char * file Source file name.
uint8_t flags PBL_LOG_MSG_* flags.
uint8_t level LOG_LEVEL_* level.
uint16_t line Source line number.
const char * text Message text, NUL-terminated.
uint8_t text_len Length of text in the binary log message format.
uint32_t timestamp Time the message was logged at, in seconds, or 0 if unknown.

◆ pbl_log_backend_state

struct pbl_log_backend_state

Runtime state of a backend.

Data Fields
bool enabled Whether messages are passed to the backend.
int16_t level Highest LOG_LEVEL_* level written.

◆ pbl_log_backend

struct pbl_log_backend

Backend.

Data Fields
const struct pbl_log_backend_api * api Operations.
const char * name Name.
struct pbl_log_backend_state * state Runtime state.

Macro Definition Documentation

◆ PBL_LOG_BACKEND_DEFINE

#define PBL_LOG_BACKEND_DEFINE (   _name,
  _api,
  _level,
  _autostart 
)
Value:
static struct pbl_log_backend_state _pbl_log_backend_state_##_name = { \
.level = (_level), \
.enabled = (_autostart) \
}; \
const struct pbl_log_backend _pbl_log_backend_##_name PBL_USED PBL_ALIGNED(4) \
PBL_SECTION(".pbl_log_backends." #_name) = { \
.name = #_name, \
.api = &(_api), \
.state = &_pbl_log_backend_state_##_name, \
}
#define PBL_USED
Keep the symbol even if it appears unreferenced.
Definition compiler.h:90
#define PBL_ALIGNED(bytes)
Align the symbol or type.
Definition compiler.h:87
#define PBL_SECTION(name)
Place the symbol in a linker section.
Definition compiler.h:126
struct pbl_log_backend_state * state
Runtime state.
Definition backend.h:75
bool enabled
Whether messages are passed to the backend.
Definition backend.h:65
int16_t level
Highest LOG_LEVEL_* level written.
Definition backend.h:63
Backend.
Definition backend.h:69
Runtime state of a backend.
Definition backend.h:61

Define a backend.

Parameters
_nameBackend name, also its identifier.
_apiBackend operations.
_levelInitial highest LOG_LEVEL_* level written.
_autostartWhether the backend starts enabled, or waits for pbl_log_backend_enable.

◆ PBL_LOG_BACKEND_GET

#define PBL_LOG_BACKEND_GET (   _name)
Value:
({ \
extern const struct pbl_log_backend _pbl_log_backend_##_name; \
&_pbl_log_backend_##_name; \
})

Get a backend defined with PBL_LOG_BACKEND_DEFINE.

Parameters
_nameBackend name.

◆ PBL_LOG_MSG_ASYNC

#define PBL_LOG_MSG_ASYNC   (1U << 0)

The message may be written after pbl_log_backend_api::process returns.

◆ PBL_LOG_MSG_FAULT

#define PBL_LOG_MSG_FAULT   (1U << 1)

The message comes from a fault handler, where OS services are unavailable.

Function Documentation

◆ pbl_log_backend_disable()

void pbl_log_backend_disable ( const struct pbl_log_backend *  backend)

Stop passing messages to backend.

◆ pbl_log_backend_enable()

void pbl_log_backend_enable ( const struct pbl_log_backend *  backend)

Start passing messages to backend.

◆ pbl_log_backend_get_by_name()

const struct pbl_log_backend * pbl_log_backend_get_by_name ( const char *  name)

Find a backend by name.

Returns
The backend, or NULL if there is none called name.

◆ pbl_log_backend_is_enabled()

bool pbl_log_backend_is_enabled ( const struct pbl_log_backend *  backend)

Whether messages are passed to backend.

◆ pbl_log_backend_set_level()

void pbl_log_backend_set_level ( const struct pbl_log_backend *  backend,
int  level 
)

Set the highest LOG_LEVEL_* level written by backend.

◆ pbl_log_init()

void pbl_log_init ( void  )

Initialize the backends.

◆ pbl_log_panic()

void pbl_log_panic ( void  )

Have every backend write out its pending messages, the system is about to stop.