All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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_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_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 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.

Copyright (C) Sierra Wireless, Inc. 2014. All rights reserved. Use of this work is subject to license.

Macro Definition Documentation

#define _LE_LOG_MSG (   level,
  formatString,
  ... 
)
Value:
if ((LE_LOG_LEVEL_FILTER_PTR == NULL) || (level >= *LE_LOG_LEVEL_FILTER_PTR)) \
{ \
_le_log_Send(level, NULL, LE_LOG_SESSION, __FILE__, __func__, __LINE__, \
formatString, ##__VA_ARGS__); \
}

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

#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.

#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.

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

LE_CRIT if condition is met.

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

Debug message.

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

LE_DEBUG if condition is met.

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

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

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

LE_EMERG if condition is met.

#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.

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

LE_ERROR if condition is met.

#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).

#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).

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

Informational message. Normally expected.

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

LE_INFO if condition is met.

#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.
#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.
#define LE_TRACE (   traceRef,
  string,
  ... 
)
Value:
if (le_log_IsTraceEnabled(traceRef)) \
{ \
_le_log_Send(-1, traceRef, LE_LOG_SESSION, __FILE__, __func__, __LINE__, \
string, ##__VA_ARGS__); \
}
static bool le_log_IsTraceEnabled(const le_log_TraceRef_t traceRef)
Definition: le_log.h:585

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

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

Warning. Possibly indicates a problem. Should be addressed.

#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

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

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.
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()
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().
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.
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().
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.