XDK API  3.6.0
Documentation
Files | Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
Logging

Defines the user API for logging. More...

+ Collaboration diagram for Logging:

Files

file  BCDS_Logging.h
 

Data Structures

struct  LogAppender_T
 A log recorder operations type. More...
 
struct  LogRecorder_T
 A log recorder operations type. More...
 

Macros

#define LOG(...)   do {} while(0)
 
#define LOG_DEBUG(...)   do {} while(0)
 
#define LOG_ERROR(...)   do {} while(0)
 
#define LOG_FATAL(...)   do {} while(0)
 
#define LOG_INFO(...)   do {} while(0)
 
#define LOG_LEVEL_COMPOSE(a, b)   (a ## b)
 
#define LOG_LEVEL_GET_CURRENT()   (MIN(LOG_LEVEL_GET_CURRENT_PACKAGE(), LOG_LEVEL_GET_CURRENT_MODULE()))
 A macro to get log level for the current package module. More...
 
#define LOG_LEVEL_GET_CURRENT_MODULE()   (LOG_LEVEL_VAR(BCDS_MODULE_ID))
 A macro to get current module log level. More...
 
#define LOG_LEVEL_GET_CURRENT_PACKAGE()   (LOG_LEVEL_VAR(BCDS_PACKAGE_ID))
 A macro to get current package log level. More...
 
#define LOG_LEVEL_SET_MODULE(module, level)   LOG_LEVEL_VAR(module) = (uint8_t) level;
 A macro to set module log level in runtime. More...
 
#define LOG_LEVEL_SET_PACKAGE(package, level)   LOG_LEVEL_VAR(package) = (uint8_t) level;
 A macro to set package log level in runtime. More...
 
#define LOG_LEVEL_VAR(a)   LOG_LEVEL_COMPOSE(__log_level_, a)
 
#define LOG_WARNING(...)   do {} while(0)
 
#define MIN(a, b)   (((a) < (b)) ? (a) : (b))
 

Typedefs

typedef Retcode_T(* LogAppenderInit_T )(void *wakeup)
 A function pointer type to log appender initializer. More...
 
typedef Retcode_T(* LogAppenderWrite_T )(const char *message, uint32_t length)
 A function pointer type to log appender writer. More...
 
typedef uint32_t LogFilterId_T
 Log filter id type. More...
 
typedef Retcode_T(* LogRecordDeinit_T )(void *self)
 A function pointer type to log recorder deinitializer. More...
 
typedef Retcode_T(* LogRecordInit_T )(void *self)
 A function pointer type to log recorder initializer. More...
 
typedef Retcode_T(* LogRecordWrite_T )(LogLevel_T level, uint8_t package, uint8_t module, const char *file, uint32_t line, const char *fmt, va_list args)
 A function pointer type to log recorder writer. More...
 
typedef __builtin_va_list va_list
 

Enumerations

enum  LogLevel_T
 Enumeration of supported log levels. More...
 

Functions

uint8_t LOG_LEVEL_VAR (BCDS_PACKAGE_ID)
 External reference to package log level variable. More...
 
uint8_t LOG_LEVEL_VAR (BCDS_MODULE_ID)
 External reference to module log level variable. More...
 
LogFilterId_T LogFilter_Add (LogLevel_T level, uint8_t package, uint8_t module)
 Adds log filter item. More...
 
bool LogFilter_Apply (LogLevel_T level, uint8_t package, uint8_t module)
 An internal function to check if there is matching filter present. More...
 
Retcode_T LogFilter_Configure (LogFilterId_T id, LogLevel_T level, uint8_t package, uint8_t module)
 Modifies existing log filter item. More...
 
Retcode_T LogFilter_Delete (LogFilterId_T id)
 Deletes log filter item. More...
 
Retcode_T Logging_Init (const LogRecorder_T *recorder, const LogAppender_T *appender)
 Initializes the log recorder and appender engines. More...
 
Retcode_T Logging_Log (LogLevel_T level, uint8_t package, uint8_t module, const char *file, uint32_t line, const char *fmt,...)
 Log a message. More...
 

Variables

const LogRecorder_TLogging_AsyncRecorder
 External reference to log asynchronous recorder. More...
 
const LogAppender_TLogging_ExtFlashMemAppender
 External reference to log external flash appender. More...
 
const LogAppender_TLogging_SwoAppender
 External reference to log SWO appender. More...
 
const LogRecorder_TLogging_SyncRecorder
 External reference to log synchronous recorder. More...
 
const LogAppender_TLogging_UARTAppender
 External reference to log UART appender. More...
 

Detailed Description

By default the package and module log levels are set to LOG_LEVEL_PACKAGE_DEFAULT and LOG_LEVEL_MODULE_DEFAULT correspondingly. To override default setting the LOG_LEVEL_PACKAGE and LOG_LEVEL_MODULE should be defined before including the BCDS_Logging.h:

// example of overriding package and module default log levels
#define LOG_LEVEL_PACKAGE LOG_LEVEL_DEBUG
#define LOG_LEVEL_MODULE LOG_LEVEL_DEBUG
#include "BCDS_Logging.h"
...
// example of usage the Logging
#include "BCDS_Logging.h"
Retcode_T MainInit(void)
{
// Initialize the logging engine
if (RETCODE_OK != retcode)
{
return retcode;
}
LOG_INFO("Logging has been initialized successfully");
...
return retcode;
}

Data Structure Documentation

struct LogAppender_T

Data Fields

LogAppenderInit_T Init
 
LogAppenderWrite_T Write
 

Field Documentation

struct LogRecorder_T
+ Collaboration diagram for LogRecorder_T:

Data Fields

LogAppender_T Appender
 
LogRecordDeinit_T Deinit
 
LogRecordInit_T Init
 
void * Wakeup
 
LogRecordWrite_T Write
 

Field Documentation

LogAppender_T Appender
void* Wakeup

Macro Definition Documentation

#define LOG (   ...)    do {} while(0)
#define LOG_DEBUG (   ...)    do {} while(0)
#define LOG_ERROR (   ...)    do {} while(0)
#define LOG_FATAL (   ...)    do {} while(0)
#define LOG_INFO (   ...)    do {} while(0)
#define LOG_LEVEL_COMPOSE (   a,
 
)    (a ## b)
#define LOG_LEVEL_GET_CURRENT ( )    (MIN(LOG_LEVEL_GET_CURRENT_PACKAGE(), LOG_LEVEL_GET_CURRENT_MODULE()))
Returns
The current package module log level.
#define LOG_LEVEL_GET_CURRENT_MODULE ( )    (LOG_LEVEL_VAR(BCDS_MODULE_ID))
Return values
Amodule log level.
#define LOG_LEVEL_GET_CURRENT_PACKAGE ( )    (LOG_LEVEL_VAR(BCDS_PACKAGE_ID))
Return values
Apackage log level.
#define LOG_LEVEL_SET_MODULE (   module,
  level 
)    LOG_LEVEL_VAR(module) = (uint8_t) level;
Parameters
[in]moduleA module id.
[in]levelA log level to be set for the module.
#define LOG_LEVEL_SET_PACKAGE (   package,
  level 
)    LOG_LEVEL_VAR(package) = (uint8_t) level;
Parameters
[in]packageA package id.
[in]levelA log level to be set for the package.
#define LOG_LEVEL_VAR (   a)    LOG_LEVEL_COMPOSE(__log_level_, a)
#define LOG_WARNING (   ...)    do {} while(0)
#define MIN (   a,
 
)    (((a) < (b)) ? (a) : (b))

Typedef Documentation

typedef Retcode_T(* LogAppenderInit_T)(void *wakeup)
typedef Retcode_T(* LogAppenderWrite_T)(const char *message, uint32_t length)
typedef uint32_t LogFilterId_T
typedef Retcode_T(* LogRecordDeinit_T)(void *self)
typedef Retcode_T(* LogRecordInit_T)(void *self)
typedef Retcode_T(* LogRecordWrite_T)(LogLevel_T level, uint8_t package, uint8_t module, const char *file, uint32_t line, const char *fmt, va_list args)
typedef __builtin_va_list va_list

Enumeration Type Documentation

enum LogLevel_T
Enumerator
LOG_LEVEL_NONE 
LOG_LEVEL_FATAL 
LOG_LEVEL_ERROR 
LOG_LEVEL_WARNING 
LOG_LEVEL_INFO 
LOG_LEVEL_DEBUG 
LOG_LEVEL_COUNT 

Function Documentation

uint8_t LOG_LEVEL_VAR ( BCDS_PACKAGE_ID  )
uint8_t LOG_LEVEL_VAR ( BCDS_MODULE_ID  )
LogFilterId_T LogFilter_Add ( LogLevel_T  level,
uint8_t  package,
uint8_t  module 
)
Parameters
[in]levelA filter log level.
[in]packageA filter log package id.
[in]moduleA filter log module id.
Returns
A filter id if successfully added, LOG_FILTER_ID_INVALID (see LOG_FILTER_ITEM_COUNT set to same value) otherwise.
bool LogFilter_Apply ( LogLevel_T  level,
uint8_t  package,
uint8_t  module 
)
Parameters
[in]levelA log level.
[in]packageA package id.
[in]moduleA log module id.
Returns
True if the matching filter present or the latter is inactive, false otherwise.
Retcode_T LogFilter_Configure ( LogFilterId_T  id,
LogLevel_T  level,
uint8_t  package,
uint8_t  module 
)
Parameters
[in]idA filter id.
[in]levelA new filter log level.
[in]packageA new filter log package id.
[in]moduleA new filter log module id.
Return values
RETCODE_OKif filter is successfully configured
RETCODE_INVALID_PARAMif id is bigger than LOG_FILTER_ITEM_COUNT
Retcode_T LogFilter_Delete ( LogFilterId_T  id)
Parameters
[in]idA filter id to be removed.
Return values
RETCODE_OKif successfully deleted
RETCODE_INVALID_PARAMif id is bigger than LOG_FILTER_ITEM_COUNT
Retcode_T Logging_Init ( const LogRecorder_T recorder,
const LogAppender_T appender 
)
Parameters
[in]recorderA log recorder implementation.
[in]appenderA log appender implementation.
Return values
RETCODE_OKif successfully initialized
RETCODE_INVALID_PARAMif recorder pointer, any of recorder pointer attributes (see LogRecorder_T) or appender pointer, any of appender pointer attributes (see LogAppender_T) is null
Returns
errors from recorder.init (see LogRecordInit_T) or from appender.Init (see LogAppenderInit_T) will be returned
Retcode_T Logging_Log ( LogLevel_T  level,
uint8_t  package,
uint8_t  module,
const char *  file,
uint32_t  line,
const char *  fmt,
  ... 
)
Return values
RETCODE_OKif successfully executed
RETCODE_UNINITIALIZEDif the logger has not been initialized previously
RETCODE_NOT_SUPPORTEDif there is no matching filter (see LogFilter_Apply)
Returns
#errors from recorder.Write (see LogRecorder_T.Write) will be returned

Variable Documentation

const LogRecorder_T* Logging_AsyncRecorder
const LogAppender_T* Logging_ExtFlashMemAppender
const LogAppender_T* Logging_SwoAppender
const LogRecorder_T* Logging_SyncRecorder
const LogAppender_T* Logging_UARTAppender

All rights reserved. The use is subject to the XDK SDK EULA by Bosch Connected Devices and Solutions GmbH.
This documentation file has been automatically generated on Thu Mar 14 2019 19:12:52 by doxygen 1.8.8