ADTF
builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/log.h File Reference

Copyright © Audi Electronics Venture GmbH. More...

Go to the source code of this file.

Classes

struct  tLogEntry
 A log entry. More...
 

Namespaces

 A_UTILS_NS
 ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
 
 A_UTILS_NS::log
 namespace for default logging functionality within A_UTILS_NS
 

Macros

#define LOG_RESULT(code)
 Log result to console. More...
 
#define RETURN_AND_LOG_ERROR(code)
 Log error code to console and return from the current function. More...
 
#define RETURN_AND_LOG_ERROR_STR(code, ...)
 Log custom error description to console and return from the current function. More...
 
#define RETURN_IF_FAILED_AND_LOG_ERROR_STR(code, ...)
 Log custom error description to console and return from the current function. More...
 
#define _A_UTILS_STRINGIFY(__number)   #__number
 internal
 
#define _A_UTILS_TO_STRING(__number)   _A_UTILS_STRINGIFY(__number)
 internal
 
#define LOG_ADD_ENTRY(__level, ...)
 internal More...
 
#define LOG_DUMP(...)
 Logs a dump message.
 
#define LOG_DETAIL(...)   LOG_ADD_ENTRY(A_UTILS_NS::log::tLogLevel::Detail, __VA_ARGS__)
 Logs additional information.
 
#define LOG_INFO(...)   LOG_ADD_ENTRY(A_UTILS_NS::log::tLogLevel::Info, __VA_ARGS__)
 Logs an info message.
 
#define LOG_WARNING(...)   LOG_ADD_ENTRY(A_UTILS_NS::log::tLogLevel::Warning, __VA_ARGS__)
 Logs a warning message.
 
#define LOG_ERROR(...)   LOG_ADD_ENTRY(A_UTILS_NS::log::tLogLevel::Error, __VA_ARGS__)
 Logs an error message.
 

Typedefs

typedef std::function< tVoid(const tLogEntry &sEntry)> logger
 Logger interface definition.
 

Enumerations

enum  tLogLevel {
  None = 0 , Error = 10 , Warning = 20 , Info = 30 ,
  Detail = 35 , Dump = 40 , Debug = Dump , All = 0xFF
}
 Log levels.
 

Functions

tVoid add_entry (const tLogEntry &sEntry)
 Adds a new log entry to the current logger. More...
 
tTimeStamp log_get_current_date_time ()
 Internal helper to hide cDateTime::GetCurrentDateTime.
 
tVoid add_entry (tUInt8 nLogLevel, const tChar *strMessage=nullptr, const tChar *strSource=nullptr)
 Adds a new log entry to the current logger. More...
 
tVoid set_logger (logger oLogger)
 Sets the currently used logger. More...
 
logger get_logger ()
 Returns the currently used logger. More...
 
tVoid default_logger (const tLogEntry &sEntry)
 Default logging method, that writes log messages to stdout. More...
 
tVoid set_filtered_logging (tUInt8 nMaxLogLevel, logger oLogger=default_logger)
 Convenience method to filter log messages. More...
 

Detailed Description

Copyright © Audi Electronics Venture GmbH.

All rights reserved

Definition in file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/log.h.

Macro Definition Documentation

◆ LOG_ADD_ENTRY

#define LOG_ADD_ENTRY (   __level,
  ... 
)
Value:
A_UTILS_NS::detail::format(__VA_ARGS__).c_str(),\
A_UTILS_NS::detail::format("%s:%d(%s)", __FILE__, __LINE__, __FUNC__).c_str())
tVoid add_entry(const tLogEntry &sEntry)
Adds a new log entry to the current logger.

internal

Definition at line 171 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/log.h.

◆ LOG_RESULT

#define LOG_RESULT (   code)
Value:
do\
{ \
tResult _result = code; \
if (IS_OK(_result))\
{\
LOG_INFO("%s", A_UTILS_NS::detail::to_string(_result).c_str());\
} \
else \
{\
LOG_ERROR("%s", A_UTILS_NS::detail::to_string(_result).c_str());\
} \
} \
while(tFalse)
#define tFalse
Value for tBool.
Definition: constants.h:60

Log result to console.

Definition at line 15 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/log.h.

◆ RETURN_AND_LOG_ERROR

#define RETURN_AND_LOG_ERROR (   code)
Value:
do\
{ \
tResult _result = code; \
LOG_RESULT(_result); \
return (_result); \
}\
while(tFalse)

Log error code to console and return from the current function.

This requires the calling function's return type to be tResult.

Definition at line 32 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/log.h.

◆ RETURN_AND_LOG_ERROR_STR

#define RETURN_AND_LOG_ERROR_STR (   code,
  ... 
)
Value:
do\
{ \
LOG_ERROR(__VA_ARGS__); \
return (code); \
}\
while(tFalse)

Log custom error description to console and return from the current function.

This requires the calling function's return type to be tResult.

Definition at line 43 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/log.h.

◆ RETURN_IF_FAILED_AND_LOG_ERROR_STR

#define RETURN_IF_FAILED_AND_LOG_ERROR_STR (   code,
  ... 
)
Value:
do\
{ \
tResult _outer_result = code; \
if (IS_FAILED(_outer_result)) \
{\
LOG_ERROR(__VA_ARGS__); \
LOG_RESULT(_outer_result);\
return _outer_result;\
} \
}\
while(tFalse)

Log custom error description to console and return from the current function.

This requires the calling function's return type to be tResult.

Definition at line 53 of file builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/src/libraries/a_utils/include/a_utils/std/log.h.