le_log.h File Reference

Go to the source code of this file.

Macros

#define _LE_LOG_MSG(level, formatString, ...)
 
#define LE_DEBUG(formatString, ...)   _LE_LOG_MSG(LE_LOG_DEBUG, formatString, ##__VA_ARGS__)
 Debug message. More...
 
#define LE_DUMP(dataPtr, dataLength)   _le_LogData(dataPtr, dataLength, STRINGIZE(LE_FILENAME), __func__, __LINE__)
 
#define LE_INFO(formatString, ...)   _LE_LOG_MSG(LE_LOG_INFO, formatString, ##__VA_ARGS__)
 Informational message. Normally expected. More...
 
#define LE_WARN(formatString, ...)   _LE_LOG_MSG(LE_LOG_WARN, formatString, ##__VA_ARGS__)
 Warning. Possibly indicates a problem. Should be addressed. More...
 
#define LE_ERROR(formatString, ...)   _LE_LOG_MSG(LE_LOG_ERR, formatString, ##__VA_ARGS__)
 
#define LE_CRIT(formatString, ...)   _LE_LOG_MSG(LE_LOG_CRIT, formatString, ##__VA_ARGS__)
 
#define LE_EMERG(formatString, ...)   _LE_LOG_MSG(LE_LOG_EMERG, formatString, ##__VA_ARGS__)
 Emergency. A fatal error has occurred. A process is being terminated. More...
 
#define LE_DEBUG_IF(condition, formatString, ...)   if (condition) { _LE_LOG_MSG(LE_LOG_DEBUG, formatString, ##__VA_ARGS__); }
 
#define LE_INFO_IF(condition, formatString, ...)   if (condition) { _LE_LOG_MSG(LE_LOG_INFO, formatString, ##__VA_ARGS__); }
 
#define LE_WARN_IF(condition, formatString, ...)   if (condition) { _LE_LOG_MSG(LE_LOG_WARN, formatString, ##__VA_ARGS__); }
 
#define LE_ERROR_IF(condition, formatString, ...)   if (condition) { _LE_LOG_MSG(LE_LOG_ERR, formatString, ##__VA_ARGS__); }
 
#define LE_CRIT_IF(condition, formatString, ...)   if (condition) { _LE_LOG_MSG(LE_LOG_CRIT, formatString, ##__VA_ARGS__); }
 
#define LE_EMERG_IF(condition, formatString, ...)   if (condition) { _LE_LOG_MSG(LE_LOG_EMERG, formatString, ##__VA_ARGS__); }
 
#define LE_FATAL(formatString, ...)   { LE_EMERG(formatString, ##__VA_ARGS__); exit(EXIT_FAILURE); }
 
#define LE_FATAL_IF(condition, formatString, ...)   if (condition) { LE_FATAL(formatString, ##__VA_ARGS__) }
 
#define LE_ASSERT(condition)   if (!(condition)) { LE_FATAL("Assert Failed: '%s'", #condition) }
 
#define LE_ASSERT_OK(condition)   if ((condition) != LE_OK) { LE_FATAL("Assert Failed: '%s' is not LE_OK (0)", #condition) }
 
#define LE_RESULT_TXT(v)   _le_log_GetResultCodeString(v)
 
#define LE_IS_TRACE_ENABLED(traceRef)   (le_log_IsTraceEnabled(traceRef))
 
#define LE_TRACE(traceRef, string, ...)
 

Enumerations

enum  le_log_Level_t {
  LE_LOG_DEBUG, LE_LOG_INFO, LE_LOG_WARN, LE_LOG_ERR,
  LE_LOG_CRIT, LE_LOG_EMERG
}
 

Functions

const char * _le_log_GetResultCodeString (le_result_t resultCode)
 Function that does the real work of translating result codes. See LE_RESULT_TXT. More...
 
static le_log_TraceRef_t le_log_GetTraceRef (const char *keywordPtr)
 
static bool le_log_IsTraceEnabled (const le_log_TraceRef_t traceRef)
 
static void le_log_SetFilterLevel (le_log_Level_t level)
 
static le_log_Level_t le_log_GetFilterLevel (void)
 
static void le_log_EnableTrace (const le_log_TraceRef_t traceRef)
 
static void le_log_DisableTrace (const le_log_TraceRef_t traceRef)
 

Detailed Description

Legato Logging API include file.

Macro Definition Documentation

◆ _LE_LOG_MSG

#define _LE_LOG_MSG (   level,
  formatString,
  ... 
)
Value:
do { \
if ((LE_LOG_LEVEL_FILTER_PTR == NULL) || (level >= *LE_LOG_LEVEL_FILTER_PTR)) \
_le_log_Send(level, NULL, LE_LOG_SESSION, STRINGIZE(LE_FILENAME), __func__, __LINE__, \
formatString, ##__VA_ARGS__); \
} while(0)
#define STRINGIZE(x)
Definition: le_basics.h:206

Internal macro to filter out messages that do not meet the current filtering level.

◆ LE_ASSERT

#define LE_ASSERT (   condition)    if (!(condition)) { LE_FATAL("Assert Failed: '%s'", #condition) }

This macro does nothing if the condition is true, otherwise it logs the condition expression as a message at EMERGENCY level and then kills the calling process.

◆ LE_ASSERT_OK

#define LE_ASSERT_OK (   condition)    if ((condition) != LE_OK) { LE_FATAL("Assert Failed: '%s' is not LE_OK (0)", #condition) }

This macro does nothing if the condition is LE_OK (0), otherwise it logs that the expression did not evaluate to LE_OK (0) in a message at EMERGENCY level and then kills the calling process.

◆ LE_CRIT

#define LE_CRIT (   formatString,
  ... 
)    _LE_LOG_MSG(LE_LOG_CRIT, formatString, ##__VA_ARGS__)

Critical error. Fault that almost certainly has or will result in a system failure.

◆ LE_CRIT_IF

#define LE_CRIT_IF (   condition,
  formatString,
  ... 
)    if (condition) { _LE_LOG_MSG(LE_LOG_CRIT, formatString, ##__VA_ARGS__); }

LE_CRIT if condition is met.

◆ LE_DEBUG

#define LE_DEBUG (   formatString,
  ... 
)    _LE_LOG_MSG(LE_LOG_DEBUG, formatString, ##__VA_ARGS__)

Debug message.

◆ LE_DEBUG_IF

#define LE_DEBUG_IF (   condition,
  formatString,
  ... 
)    if (condition) { _LE_LOG_MSG(LE_LOG_DEBUG, formatString, ##__VA_ARGS__); }

LE_DEBUG if condition is met.

◆ LE_DUMP

#define LE_DUMP (   dataPtr,
  dataLength 
)    _le_LogData(dataPtr, dataLength, STRINGIZE(LE_FILENAME), __func__, __LINE__)

◆ LE_EMERG

#define LE_EMERG (   formatString,
  ... 
)    _LE_LOG_MSG(LE_LOG_EMERG, formatString, ##__VA_ARGS__)

Emergency. A fatal error has occurred. A process is being terminated.

◆ LE_EMERG_IF

#define LE_EMERG_IF (   condition,
  formatString,
  ... 
)    if (condition) { _LE_LOG_MSG(LE_LOG_EMERG, formatString, ##__VA_ARGS__); }

LE_EMERG if condition is met.

◆ LE_ERROR

#define LE_ERROR (   formatString,
  ... 
)    _LE_LOG_MSG(LE_LOG_ERR, formatString, ##__VA_ARGS__)

Error. Definitely indicates a fault that needs to be addressed. Possibly resulted in a system failure.

◆ LE_ERROR_IF

#define LE_ERROR_IF (   condition,
  formatString,
  ... 
)    if (condition) { _LE_LOG_MSG(LE_LOG_ERR, formatString, ##__VA_ARGS__); }

LE_ERROR if condition is met.

◆ LE_FATAL

#define LE_FATAL (   formatString,
  ... 
)    { LE_EMERG(formatString, ##__VA_ARGS__); exit(EXIT_FAILURE); }

Log fatal errors by killing the calling process after logging the message at EMERGENCY level. This macro never returns.

Accepts printf-style arguments, consisting of a format string followed by zero or more parameters to be printed (depending on the contents of the format string).

◆ LE_FATAL_IF

#define LE_FATAL_IF (   condition,
  formatString,
  ... 
)    if (condition) { LE_FATAL(formatString, ##__VA_ARGS__) }

This macro does nothing if the condition is false, otherwise it logs the message at EMERGENCY level and then kills the calling process.

Accepts printf-style arguments, consisting of a format string followed by zero or more parameters to be printed (depending on the contents of the format string).

◆ LE_INFO

#define LE_INFO (   formatString,
  ... 
)    _LE_LOG_MSG(LE_LOG_INFO, formatString, ##__VA_ARGS__)

Informational message. Normally expected.

◆ LE_INFO_IF

#define LE_INFO_IF (   condition,
  formatString,
  ... 
)    if (condition) { _LE_LOG_MSG(LE_LOG_INFO, formatString, ##__VA_ARGS__); }

LE_INFO if condition is met.

◆ LE_IS_TRACE_ENABLED

#define LE_IS_TRACE_ENABLED (   traceRef)    (le_log_IsTraceEnabled(traceRef))

Queries whether or not a trace keyword is enabled.

Returns
true if the keyword is enabled. false otherwise.

◆ LE_RESULT_TXT

#define LE_RESULT_TXT (   v)    _le_log_GetResultCodeString(v)

Get a null-terminated, printable string representing an le_result_t value.

For example, LE_RESULT_TXT(LE_NOT_PERMITTED) would return a pointer to a string containing "LE_NOT_PERMITTED".

"(unknown)" will be returned if the value given is out of range.

Returns
Pointer to a string constant.

◆ LE_TRACE

#define LE_TRACE (   traceRef,
  string,
  ... 
)
Value:
if (le_log_IsTraceEnabled(traceRef)) \
{ \
_le_log_Send((le_log_Level_t)-1, \
traceRef, \
LE_LOG_SESSION, \
STRINGIZE(LE_FILENAME), \
__func__, \
__LINE__, \
string, \
##__VA_ARGS__); \
}
#define STRINGIZE(x)
Definition: le_basics.h:206
le_log_Level_t
Definition: le_log.h:374
static bool le_log_IsTraceEnabled(const le_log_TraceRef_t traceRef)
Definition: le_log.h:650

Logs the string if the keyword has been enabled by a runtime tool or configuration setting.

◆ LE_WARN

#define LE_WARN (   formatString,
  ... 
)    _LE_LOG_MSG(LE_LOG_WARN, formatString, ##__VA_ARGS__)

Warning. Possibly indicates a problem. Should be addressed.

◆ LE_WARN_IF

#define LE_WARN_IF (   condition,
  formatString,
  ... 
)    if (condition) { _LE_LOG_MSG(LE_LOG_WARN, formatString, ##__VA_ARGS__); }

LE_WARN if condition is met.

Enumeration Type Documentation

◆ le_log_Level_t

Local definitions that should not be used directly.

Enumerator
LE_LOG_DEBUG 

Debug message.

LE_LOG_INFO 

Informational message. Normally expected.

LE_LOG_WARN 

Warning. Possibly indicates a problem. Should be addressed.

LE_LOG_ERR 

Error. Definitely indicates a fault that needs to be addressed. Possibly resulted in a system failure.

LE_LOG_CRIT 

Critical error. Fault that almost certainly has or will result in a system failure.

LE_LOG_EMERG 

Emergency. A fatal error has occurred. A process is being terminated.

Function Documentation

◆ _le_log_GetResultCodeString()

const char* _le_log_GetResultCodeString ( le_result_t  resultCode)

Function that does the real work of translating result codes. See LE_RESULT_TXT.

Parameters
[in]resultCodeResult code value to be translated.

◆ le_log_DisableTrace()

static void le_log_DisableTrace ( const le_log_TraceRef_t  traceRef)
inlinestatic

Disables a trace.

Note
Normally, this is not necessary, since traces can be enabled at runtime using the log control tool and can be persistently configured. See Log Controls.
Parameters
[in]traceRefTrace reference obtained from le_log_GetTraceRef()

◆ le_log_EnableTrace()

static void le_log_EnableTrace ( const le_log_TraceRef_t  traceRef)
inlinestatic

Enables a trace.

Note
Normally, this is not necessary, since traces can be enabled at runtime using the log control tool and can be persistently configured. See Log Controls.
Parameters
[in]traceRefTrace reference obtained from le_log_GetTraceRef().

◆ le_log_GetFilterLevel()

static le_log_Level_t le_log_GetFilterLevel ( void  )
inlinestatic

Gets the log filter level for the calling component.

◆ le_log_GetTraceRef()

static le_log_TraceRef_t le_log_GetTraceRef ( const char *  keywordPtr)
inlinestatic

Gets a reference to a trace keyword's settings.

Returns
Trace reference.
Parameters
[in]keywordPtrPointer to the keyword string.

◆ le_log_IsTraceEnabled()

static bool le_log_IsTraceEnabled ( const le_log_TraceRef_t  traceRef)
inlinestatic

Determines if a trace is currently enabled.

Returns
true if enabled, false if not.
Parameters
[in]traceRefTrace reference obtained from le_log_GetTraceRef().

◆ le_log_SetFilterLevel()

static void le_log_SetFilterLevel ( le_log_Level_t  level)
inlinestatic

Sets the log filter level for the calling component.

Note
Normally not necessary as the log filter level can be controlled at runtime using the log control tool, and can be persistently configured. See Log Controls.
Parameters
[in]levelLog filter level to apply to the current log session.