openthread-br  0.3.0-72c0388
Macros | Enumerations | Functions
logging.hpp File Reference
#include "openthread-br/config.h"
#include <stdarg.h>
#include <stddef.h>
#include "common/types.hpp"

Go to the source code of this file.

Macros

#define otbrLogResult(aError, aFormat, ...)
 
#define otbrLogEmerg(...)   otbrLog(OTBR_LOG_EMERG, OTBR_LOG_TAG, __VA_ARGS__)
 
#define otbrLogAlert(...)   otbrLog(OTBR_LOG_ALERT, OTBR_LOG_TAG, __VA_ARGS__)
 
#define otbrLogCrit(...)   otbrLog(OTBR_LOG_CRIT, OTBR_LOG_TAG, __VA_ARGS__)
 
#define otbrLogErr(...)   otbrLog(OTBR_LOG_ERR, OTBR_LOG_TAG, __VA_ARGS__)
 
#define otbrLogWarning(...)   otbrLog(OTBR_LOG_WARNING, OTBR_LOG_TAG, __VA_ARGS__)
 
#define otbrLogNotice(...)   otbrLog(OTBR_LOG_NOTICE, OTBR_LOG_TAG, __VA_ARGS__)
 
#define otbrLogInfo(...)   otbrLog(OTBR_LOG_INFO, OTBR_LOG_TAG, __VA_ARGS__)
 
#define otbrLogDebug(...)   otbrLog(OTBR_LOG_DEBUG, OTBR_LOG_TAG, __VA_ARGS__)
 

Enumerations

enum  otbrLogLevel {
  OTBR_LOG_EMERG, OTBR_LOG_ALERT, OTBR_LOG_CRIT, OTBR_LOG_ERR,
  OTBR_LOG_WARNING, OTBR_LOG_NOTICE, OTBR_LOG_INFO, OTBR_LOG_DEBUG
}
 

Functions

otbrLogLevel otbrLogGetLevel (void)
 
void otbrLogSetLevel (otbrLogLevel aLevel)
 
void otbrLogEnableSyslog (bool aEnabled)
 
void otbrLogInit (const char *aIdent, otbrLogLevel aLevel, bool aPrintStderr)
 
void otbrLog (otbrLogLevel aLevel, const char *aLogTag, const char *aFormat,...)
 
void otbrLogv (otbrLogLevel aLevel, const char *aFormat, va_list aArgList)
 
void otbrLogvNoFilter (otbrLogLevel aLevel, const char *aFormat, va_list aArgList)
 
void otbrDump (otbrLogLevel aLevel, const char *aLogTag, const char *aPrefix, const void *aMemory, size_t aSize)
 
const char * otbrErrorString (otbrError aError)
 
void otbrLogDeinit (void)
 

Detailed Description

This file define logging interface.

Macro Definition Documentation

◆ otbrLogAlert

#define otbrLogAlert (   ...)    otbrLog(OTBR_LOG_ALERT, OTBR_LOG_TAG, __VA_ARGS__)

Log at level alert.

Parameters
[in]...Arguments for the format specification.

◆ otbrLogCrit

#define otbrLogCrit (   ...)    otbrLog(OTBR_LOG_CRIT, OTBR_LOG_TAG, __VA_ARGS__)

Log at level critical.

Parameters
[in]...Arguments for the format specification.

◆ otbrLogDebug

#define otbrLogDebug (   ...)    otbrLog(OTBR_LOG_DEBUG, OTBR_LOG_TAG, __VA_ARGS__)

Log at level debug.

Parameters
[in]...Arguments for the format specification.

◆ otbrLogEmerg

#define otbrLogEmerg (   ...)    otbrLog(OTBR_LOG_EMERG, OTBR_LOG_TAG, __VA_ARGS__)

Log at level emergency.

Parameters
[in]...Arguments for the format specification.

◆ otbrLogErr

#define otbrLogErr (   ...)    otbrLog(OTBR_LOG_ERR, OTBR_LOG_TAG, __VA_ARGS__)

Log at level error.

Parameters
[in]...Arguments for the format specification.

◆ otbrLogInfo

#define otbrLogInfo (   ...)    otbrLog(OTBR_LOG_INFO, OTBR_LOG_TAG, __VA_ARGS__)

Log at level information.

Parameters
[in]...Arguments for the format specification.

◆ otbrLogNotice

#define otbrLogNotice (   ...)    otbrLog(OTBR_LOG_NOTICE, OTBR_LOG_TAG, __VA_ARGS__)

Log at level notice.

Parameters
[in]...Arguments for the format specification.

◆ otbrLogResult

#define otbrLogResult (   aError,
  aFormat,
  ... 
)
Value:
do \
{ \
otbrError _err = (aError); \
otbrLog(_err == OTBR_ERROR_NONE ? OTBR_LOG_INFO : OTBR_LOG_WARNING, OTBR_LOG_TAG, aFormat ": %s", \
##__VA_ARGS__, otbrErrorString(_err)); \
} while (0)

This macro log an action result according to aError.

If aError is OTBR_ERROR_NONE, the log level will be OTBR_LOG_INFO, otherwise OTBR_LOG_WARNING.

Parameters
[in]aErrorThe action result.
[in]aFormatFormat string as in printf.
[in]...Arguments for the format specification.

◆ otbrLogWarning

#define otbrLogWarning (   ...)    otbrLog(OTBR_LOG_WARNING, OTBR_LOG_TAG, __VA_ARGS__)

Log at level warning.

Parameters
[in]...Arguments for the format specification.

Enumeration Type Documentation

◆ otbrLogLevel

Logging level.

Enumerator
OTBR_LOG_EMERG 

System is unusable.

OTBR_LOG_ALERT 

Action must be taken immediately.

OTBR_LOG_CRIT 

Critical conditions.

OTBR_LOG_ERR 

Error conditions.

OTBR_LOG_WARNING 

Warning conditions.

OTBR_LOG_NOTICE 

Normal but significant condition.

OTBR_LOG_INFO 

Informational.

OTBR_LOG_DEBUG 

Debug level messages.

Function Documentation

◆ otbrDump()

void otbrDump ( otbrLogLevel  aLevel,
const char *  aLogTag,
const char *  aPrefix,
const void *  aMemory,
size_t  aSize 
)

This function dump memory as hex string at level aLevel.

Parameters
[in]aLevelLog level of the logger.
[in]aLogTagLog tag.
[in]aPrefixString before dumping memory.
[in]aMemoryThe pointer to the memory to be dumped.
[in]aSizeThe size of memory in bytes to be dumped.

Hex dump data to the log

◆ otbrErrorString()

const char* otbrErrorString ( otbrError  aError)

This function converts error code to string.

Parameters
[in]aErrorThe error code.
Returns
The string information of error.

◆ otbrLog()

void otbrLog ( otbrLogLevel  aLevel,
const char *  aLogTag,
const char *  aFormat,
  ... 
)

This function log at level aLevel.

Parameters
[in]aLevelLog level of the logger.
[in]aLogTagLog tag.
[in]aFormatFormat string as in printf.

log to the syslog or log file

◆ otbrLogDeinit()

void otbrLogDeinit ( void  )

This function deinitializes the logging service.

◆ otbrLogEnableSyslog()

void otbrLogEnableSyslog ( bool  aEnabled)

Control log to syslog.

Parameters
[in]enableTrue to log to/via syslog.

◆ otbrLogGetLevel()

otbrLogLevel otbrLogGetLevel ( void  )

Get current log level.

Get the current debug log level

◆ otbrLogInit()

void otbrLogInit ( const char *  aIdent,
otbrLogLevel  aLevel,
bool  aPrintStderr 
)

This function initialize the logging service.

Parameters
[in]aIdentIdentity of the logger.
[in]aLevelLog level of the logger.
[in]aPrintStderrWhether to log to stderr.

Initialize logging

◆ otbrLogSetLevel()

void otbrLogSetLevel ( otbrLogLevel  aLevel)

Set current log level.

◆ otbrLogv()

void otbrLogv ( otbrLogLevel  aLevel,
const char *  aFormat,
va_list  aArgList 
)

This function log at level aLevel.

Parameters
[in]aLevelLog level of the logger.
[in]aFormatFormat string as in printf.
[in]aArgListThe variable-length arguments list.

log to the syslog or log file

◆ otbrLogvNoFilter()

void otbrLogvNoFilter ( otbrLogLevel  aLevel,
const char *  aFormat,
va_list  aArgList 
)

This function writes logs without filtering with the log level.

Parameters
[in]aLevelLog level of the logger.
[in]aFormatFormat string as in printf.
[in]aArgListThe variable-length arguments list.
OTBR_LOG_INFO
@ OTBR_LOG_INFO
Informational.
Definition: logging.hpp:59
OTBR_LOG_WARNING
@ OTBR_LOG_WARNING
Warning conditions.
Definition: logging.hpp:57
OTBR_ERROR_NONE
@ OTBR_ERROR_NONE
No error.
Definition: types.hpp:72
otbrErrorString
const char * otbrErrorString(otbrError aError)
Definition: logging.cpp:193