M5Utility 0.0.2 git rev:5c1a751
Loading...
Searching...
No Matches
library_log.hpp File Reference

Logging for libraries. More...

#include <cstdint>
#include <chrono>

Go to the source code of this file.

Namespaces

namespace  m5
 Top level namespace of M5.
 

Macros

#define M5_LIB_LOGE(format, ...)
 Output log (level ERROR)
 
#define M5_LIB_LOGW(format, ...)
 Output log (level WARN)
 
#define M5_LIB_LOGI(format, ...)
 Output log (level INFO)
 
#define M5_LIB_LOGD(format, ...)
 Output log (level DEBUG)
 
#define M5_LIB_LOGV(format, ...)
 Output log (level VERBOSE)
 
#define M5_DUMPE(addr, len)
 Output log (level ERROR)
 
#define M5_DUMPW(addr, len)
 Output log (level WARN)
 
#define M5_DUMPI(addr, len)
 Output log (level INFO)
 
#define M5_DUMPD(addr, len)
 Output log (level DEBUG)
 
#define M5_DUMPV(addr, len)
 Output log (level VERBOSE)
 

Typedefs

using m5::utility::log::log_level_t = LogLevel
 
using m5::utility::log::elapsed_time_t = std::chrono::milliseconds
 

Enumerations

enum class  m5::utility::log::LogLevel : uint8_t {
  None , Error , Warn , Info ,
  Debug , Verbose
}
 

Functions

constexpr const char * m5::utility::log::pathToFilename (const char *path)
 Gets the filename from full pathname.
 
void m5::utility::log::logPrintf (const char *format,...)
 Output formatted strings.
 
void m5::utility::log::dump (const void *addr, const size_t len, const bool align=true)
 Output dump.
 
elapsed_time_t m5::utility::log::elapsedTime ()
 Gets the elapsed time for log.
 

Variables

constexpr log_level_t m5::utility::log::logOutputLevel = log_level_t::None
 Base value of log level to be output.
 

Detailed Description

Logging for libraries.

Macro Definition Documentation

◆ M5_DUMPD

#define M5_DUMPD ( addr,
len )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Debug) { \
m5::utility::log::dump((addr), (len)); \
} \
} while (0)

Output log (level DEBUG)

◆ M5_DUMPE

#define M5_DUMPE ( addr,
len )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Error) { \
m5::utility::log::dump((addr), (len)); \
} \
} while (0)

Output log (level ERROR)

◆ M5_DUMPI

#define M5_DUMPI ( addr,
len )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Info) { \
m5::utility::log::dump((addr), (len)); \
} \
} while (0)

Output log (level INFO)

◆ M5_DUMPV

#define M5_DUMPV ( addr,
len )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Verbose) { \
m5::utility::log::dump((addr), (len)); \
} \
} while (0)

Output log (level VERBOSE)

◆ M5_DUMPW

#define M5_DUMPW ( addr,
len )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Warn) { \
m5::utility::log::dump((addr), (len)); \
} \
} while (0)

Output log (level WARN)

◆ M5_LIB_LOGD

#define M5_LIB_LOGD ( format,
... )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Debug) { \
m5::utility::log::logPrintf(M5_UTILITY_LOG_FORMAT(D, format), ##__VA_ARGS__); \
} \
} while (0)

Output log (level DEBUG)

◆ M5_LIB_LOGE

#define M5_LIB_LOGE ( format,
... )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Error) { \
m5::utility::log::logPrintf(M5_UTILITY_LOG_FORMAT(E, format), ##__VA_ARGS__); \
} \
} while (0)

Output log (level ERROR)

◆ M5_LIB_LOGI

#define M5_LIB_LOGI ( format,
... )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Info) { \
m5::utility::log::logPrintf(M5_UTILITY_LOG_FORMAT(I, format), ##__VA_ARGS__); \
} \
} while (0)

Output log (level INFO)

◆ M5_LIB_LOGV

#define M5_LIB_LOGV ( format,
... )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Verbose) { \
m5::utility::log::logPrintf(M5_UTILITY_LOG_FORMAT(V, format), ##__VA_ARGS__); \
} \
} while (0)

Output log (level VERBOSE)

◆ M5_LIB_LOGW

#define M5_LIB_LOGW ( format,
... )
Value:
do { \
if (m5::utility::log::logOutputLevel >= m5::utility::log::log_level_t::Warn) { \
m5::utility::log::logPrintf(M5_UTILITY_LOG_FORMAT(W, format), ##__VA_ARGS__); \
} \
} while (0)

Output log (level WARN)

Enumeration Type Documentation

◆ LogLevel

enum class m5::utility::log::LogLevel : uint8_t
strong
Enumerator
None 

No output.

Error 

Error.

Warn 

Warning.

Info 

Information.

Debug 

Debug.

Verbose 

Verbose.

Function Documentation

◆ pathToFilename()

const char * m5::utility::log::pathToFilename ( const char * path)
constexpr

Gets the filename from full pathname.

Warning
If the string is too long, the recursion depth may be too deep to fail. (If compile time calculation)

Variable Documentation

◆ logOutputLevel

log_level_t m5::utility::log::logOutputLevel = log_level_t::None
constexpr

Base value of log level to be output.

The value can be specified in the compile options. -DM5_LOG_LEVEL=[0..5] or -DCORE_LOG_LEVEL=[0...5] default as NONE

Warning
No output if NDEBUG defined