AlexaClientSDK  1.25.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Namespaces | Classes | Enumerations | Functions | Variables
alexaClientSDK::avsCommon::utils::logger Namespace Reference

Namespaces

 test
 

Classes

class  ConsoleLogger
 
class  LogEntry
 LogEntry is used to compile the log entry text to log via Logger. More...
 
class  LogEntryBuffer
 
class  LogEntryStream
 
class  Logger
 
class  LoggerSinkManager
 
class  LogLevelObserverInterface
 
class  LogStringFormatter
 
class  ModuleLogger
 
class  SinkObserverInterface
 
class  ThreadMoniker
 

Enumerations

enum  Level {
  Level::DEBUG9, Level::DEBUG8, Level::DEBUG7, Level::DEBUG6,
  Level::DEBUG5, Level::DEBUG4, Level::DEBUG3, Level::DEBUG2,
  Level::DEBUG1, Level::DEBUG0, Level::INFO, Level::WARN,
  Level::ERROR, Level::CRITICAL, Level::NONE, Level::UNKNOWN
}
 

Functions

std::shared_ptr< LoggergetConsoleLogger ()
 
std::string convertLevelToName (Level level)
 
char convertLevelToChar (Level level)
 
Level convertNameToLevel (const std::string &name)
 
std::ostream & operator<< (std::ostream &stream, Level level)
 
std::shared_ptr< LoggerACSDK_GET_SINK_LOGGER ()
 
std::shared_ptr< LoggerACSDK_GET_LOGGER_FUNCTION ()
 
void acsdkDebug9 (const LogEntry &entry)
 
void acsdkDebug8 (const LogEntry &entry)
 
void acsdkDebug7 (const LogEntry &entry)
 
void acsdkDebug6 (const LogEntry &entry)
 
void acsdkDebug5 (const LogEntry &entry)
 
void acsdkDebug4 (const LogEntry &entry)
 
void acsdkDebug3 (const LogEntry &entry)
 
void acsdkDebug2 (const LogEntry &entry)
 
void acsdkDebug1 (const LogEntry &entry)
 
void acsdkDebug0 (const LogEntry &entry)
 
void acsdkDebug (const LogEntry &entry)
 
void acsdkInfo (const LogEntry &entry)
 
void acsdkWarn (const LogEntry &entry)
 
void acsdkError (const LogEntry &entry)
 
void acsdkCritical (const LogEntry &entry)
 
void logEntry (Level level, const LogEntry &entry)
 
void dumpBytesToStream (std::ostream &stream, const char *prefix, size_t width, const unsigned char *data, size_t size)
 
static std::atomic< int > g_nextThreadMoniker (1)
 Counter to generate (small) unique thread monikers. More...
 
std::shared_ptr< LoggergetLoggerTestLogger ()
 

Variables

static const std::string CONFIG_KEY_DEFAULT_LOGGER = "consoleLogger"
 Configuration key for DefaultLogger settings. More...
 
static const char * RESERVED_METADATA_CHARS = R"(\,=:)"
 List of characters we need to escape. More...
 
static const std::string ESCAPED_METADATA_ESCAPE = R"(\\)"
 Escape sequence for ''. More...
 
static const std::string ESCAPED_PAIR_SEPARATOR = R"(\,)"
 Escape sequence for ','. More...
 
static const std::string ESCAPED_SECTION_SEPARATOR = R"(\:)"
 Escape sequence for ':'. More...
 
static const std::string ESCAPED_KEY_VALUE_SEPARATOR = R"(\=)"
 Escape sequence for '='. More...
 
static const char METADATA_ESCAPE = '\\'
 Reserved in metadata sequences for escaping other reserved values. More...
 
static const char PAIR_SEPARATOR = ','
 Reserved in metadata sequences to separate key,value pairs. More...
 
static const char SECTION_SEPARATOR = ':'
 Reserved in metadata sequences to separate them from a preceding event and an optional terminal message. More...
 
static const std::string BOOL_TRUE = "true"
 String for boolean TRUE. More...
 
static const std::string BOOL_FALSE = "false"
 String for boolean FALSE. More...
 
static const std::string CONFIG_KEY_LOGGER = "logger"
 Configuration key for root level "logger" object. More...
 
static const std::string CONFIG_KEY_LOG_LEVEL = "logLevel"
 Configuration key for "logLevel" values under "logger" and other per-module objects. More...
 
static constexpr auto AT_EXIT_THREAD_ID = "0"
 
static const char * STRFTIME_FORMAT_STRING = "%Y-%m-%d %H:%M:%S"
 Format string for strftime() to produce date and time in the format "YYYY-MM-DD HH:MM:SS". More...
 
static const int DATE_AND_TIME_STRING_SIZE = 20
 Size of buffer needed to hold "YYYY-MM-DD HH:MM:SS" and a null terminator. More...
 
static const char TIME_AND_MILLIS_SEPARATOR = '.'
 Separator between date/time and millis. More...
 
static const char * MILLIS_FORMAT_STRING = "%03d"
 
static const int MILLIS_STRING_SIZE = 4
 Size of buffer needed to hold "nnn" (milliseconds value) and a null terminator. More...
 
static const std::string MILLIS_AND_THREAD_SEPARATOR = " ["
 Separator string between milliseconds value and ExampleLogger name. More...
 
static const std::string THREAD_AND_LEVEL_SEPARATOR = "] "
 Separator between thread ID and level indicator in log lines. More...
 
static const char LEVEL_AND_TEXT_SEPARATOR = ' '
 Separator between level indicator and text in log lines. More...
 
static const int MILLISECONDS_PER_SECOND = 1000
 Number of milliseconds per second. More...
 

Enumeration Type Documentation

◆ Level

Enum used to specify the severity assigned to a log message.

Enumerator
DEBUG9 

Most verbose debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG8 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG7 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG6 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG5 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG4 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG3 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG2 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG1 

Intermediate debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

DEBUG0 

Least verbose debug log level. Compiled out when ACSDK_DEBUG_LOG_ENABLED is not defined.

INFO 

Logs of normal operations, to be used in release builds.

WARN 

Log of an event that may indicate a problem.

ERROR 

Log of an event that indicates an error.

CRITICAL 

Log of a event that indicates an unrecoverable error.

NONE 

Level used to disable all logging.

UNKNOWN 

An unknown severity level.

Function Documentation

◆ ACSDK_GET_LOGGER_FUNCTION()

std::shared_ptr<Logger> alexaClientSDK::avsCommon::utils::logger::ACSDK_GET_LOGGER_FUNCTION ( )
inline

Inline method to get the function that ACSDK_<LEVEL> macros will send logs to. In this case ACSDK_LOG_MODULE was not defined, so logs are sent to the Logger returned by get<ACSDK_LOG_SINK>Logger().

◆ ACSDK_GET_SINK_LOGGER()

std::shared_ptr<Logger> alexaClientSDK::avsCommon::utils::logger::ACSDK_GET_SINK_LOGGER ( )

Get the Logger that logs should be sent to.

Returns
The Logger that logs should be sent to.

◆ acsdkCritical()

void alexaClientSDK::avsCommon::utils::logger::acsdkCritical ( const LogEntry entry)

Log a Level::CRITICAL severity entry.

Parameters
entryA log entry.

◆ acsdkDebug()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug ( const LogEntry entry)

Log a LEVEL::DEBUG0 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug0()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug0 ( const LogEntry entry)

Log a LEVEL::DEBUG0 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug1()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug1 ( const LogEntry entry)

Log a LEVEL::DEBUG1 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug2()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug2 ( const LogEntry entry)

Log a LEVEL::DEBUG2 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug3()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug3 ( const LogEntry entry)

Log a LEVEL::DEBUG3 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug4()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug4 ( const LogEntry entry)

Log a LEVEL::DEBUG4 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug5()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug5 ( const LogEntry entry)

Log a LEVEL::DEBUG5 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug6()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug6 ( const LogEntry entry)

Log a LEVEL::DEBUG6 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug7()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug7 ( const LogEntry entry)

Log a LEVEL::DEBUG7 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug8()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug8 ( const LogEntry entry)

Log a LEVEL::DEBUG8 severity entry.

Parameters
entryA log entry.

◆ acsdkDebug9()

void alexaClientSDK::avsCommon::utils::logger::acsdkDebug9 ( const LogEntry entry)

Log a LEVEL::DEBUG9 severity entry.

Parameters
entryA log entry.

◆ acsdkError()

void alexaClientSDK::avsCommon::utils::logger::acsdkError ( const LogEntry entry)

Log a Level::ERROR severity entry.

Parameters
entryA log entry.

◆ acsdkInfo()

void alexaClientSDK::avsCommon::utils::logger::acsdkInfo ( const LogEntry entry)

Log a Level::INFO severity entry.

Parameters
entryA log entry.

◆ acsdkWarn()

void alexaClientSDK::avsCommon::utils::logger::acsdkWarn ( const LogEntry entry)

Log a Level::WARN severity entry.

Parameters
entryA log entry.

◆ convertLevelToChar()

char alexaClientSDK::avsCommon::utils::logger::convertLevelToChar ( Level  level)

Get a character corresponding to a Level value. The characters returned are unique per log level and are intended to be used to minimize the space taken up by the level specifier in log lines.

Parameters
levelThe Level for which to get the corresponding character.
Returns
The character corresponding to the level. If the level is not recognized, returns 'U'.

◆ convertLevelToName()

std::string alexaClientSDK::avsCommon::utils::logger::convertLevelToName ( Level  level)

Get the name of a Level value.

Parameters
levelThe Level to get the name of.
Returns
Returns the name of the Level. If the level is not recognized, returns "UNKNOWN".

◆ convertNameToLevel()

Level alexaClientSDK::avsCommon::utils::logger::convertNameToLevel ( const std::string &  name)

Get the Level corresponding to a Level name.

Parameters
nameThe name corresponding to the desired Level value.
Returns
The Level corresponding to the specified name. If the name is not recognized, returns Level::UNKNOWN.

◆ dumpBytesToStream()

void alexaClientSDK::avsCommon::utils::logger::dumpBytesToStream ( std::ostream &  stream,
const char *  prefix,
size_t  width,
const unsigned char *  data,
size_t  size 
)

Stream out an array of bytes as a hex dump.

Parameters
streamThe stream to render to.
prefixA prefix added to each row.
widthThe number of bytes to output per row.
dataThe bytes to render.
sizeThe number of bytes to render.

◆ g_nextThreadMoniker()

static std::atomic<int> alexaClientSDK::avsCommon::utils::logger::g_nextThreadMoniker ( )
static

Counter to generate (small) unique thread monikers.

◆ getConsoleLogger()

std::shared_ptr< Logger > alexaClientSDK::avsCommon::utils::logger::getConsoleLogger ( )

Return the singleton instance of ConsoleLogger.

Returns
The singleton instance of ConsoleLogger.

◆ getLoggerTestLogger()

std::shared_ptr<Logger> alexaClientSDK::avsCommon::utils::logger::getLoggerTestLogger ( )

Function for ACSDK_* macros to use to get the Logger to use.

Returns
The Logger to use.

◆ logEntry()

void alexaClientSDK::avsCommon::utils::logger::logEntry ( Level  level,
const LogEntry entry 
)

Logs an entry at a severity level using the logger instance defined by ACSDK_GET_LOGGER_FUNCTION (refer to Logger.h).

Parameters
levelThe severity level of the log.
entryA log entry.

◆ operator<<()

std::ostream& alexaClientSDK::avsCommon::utils::logger::operator<< ( std::ostream &  stream,
Level  level 
)
inline

Write a log severity Level value to an ostream as a string.

Parameters
streamThe stream to write the value to.
levelThe Level value to write to the ostream as a string.
Returns
The ostream that was passed in and written to.

Variable Documentation

◆ AT_EXIT_THREAD_ID

constexpr auto alexaClientSDK::avsCommon::utils::logger::AT_EXIT_THREAD_ID = "0"
static

◆ BOOL_FALSE

const std::string alexaClientSDK::avsCommon::utils::logger::BOOL_FALSE = "false"
static

String for boolean FALSE.

◆ BOOL_TRUE

const std::string alexaClientSDK::avsCommon::utils::logger::BOOL_TRUE = "true"
static

String for boolean TRUE.

◆ CONFIG_KEY_DEFAULT_LOGGER

const std::string alexaClientSDK::avsCommon::utils::logger::CONFIG_KEY_DEFAULT_LOGGER = "consoleLogger"
static

Configuration key for DefaultLogger settings.

◆ CONFIG_KEY_LOG_LEVEL

const std::string alexaClientSDK::avsCommon::utils::logger::CONFIG_KEY_LOG_LEVEL = "logLevel"
static

Configuration key for "logLevel" values under "logger" and other per-module objects.

◆ CONFIG_KEY_LOGGER

const std::string alexaClientSDK::avsCommon::utils::logger::CONFIG_KEY_LOGGER = "logger"
static

Configuration key for root level "logger" object.

◆ DATE_AND_TIME_STRING_SIZE

const int alexaClientSDK::avsCommon::utils::logger::DATE_AND_TIME_STRING_SIZE = 20
static

Size of buffer needed to hold "YYYY-MM-DD HH:MM:SS" and a null terminator.

◆ ESCAPED_KEY_VALUE_SEPARATOR

const std::string alexaClientSDK::avsCommon::utils::logger::ESCAPED_KEY_VALUE_SEPARATOR = R"(\=)"
static

Escape sequence for '='.

◆ ESCAPED_METADATA_ESCAPE

const std::string alexaClientSDK::avsCommon::utils::logger::ESCAPED_METADATA_ESCAPE = R"(\\)"
static

Escape sequence for ''.

◆ ESCAPED_PAIR_SEPARATOR

const std::string alexaClientSDK::avsCommon::utils::logger::ESCAPED_PAIR_SEPARATOR = R"(\,)"
static

Escape sequence for ','.

◆ ESCAPED_SECTION_SEPARATOR

const std::string alexaClientSDK::avsCommon::utils::logger::ESCAPED_SECTION_SEPARATOR = R"(\:)"
static

Escape sequence for ':'.

◆ LEVEL_AND_TEXT_SEPARATOR

const char alexaClientSDK::avsCommon::utils::logger::LEVEL_AND_TEXT_SEPARATOR = ' '
static

Separator between level indicator and text in log lines.

◆ METADATA_ESCAPE

const char alexaClientSDK::avsCommon::utils::logger::METADATA_ESCAPE = '\\'
static

Reserved in metadata sequences for escaping other reserved values.

◆ MILLIS_AND_THREAD_SEPARATOR

const std::string alexaClientSDK::avsCommon::utils::logger::MILLIS_AND_THREAD_SEPARATOR = " ["
static

Separator string between milliseconds value and ExampleLogger name.

◆ MILLIS_FORMAT_STRING

const char* alexaClientSDK::avsCommon::utils::logger::MILLIS_FORMAT_STRING = "%03d"
static

◆ MILLIS_STRING_SIZE

const int alexaClientSDK::avsCommon::utils::logger::MILLIS_STRING_SIZE = 4
static

Size of buffer needed to hold "nnn" (milliseconds value) and a null terminator.

◆ MILLISECONDS_PER_SECOND

const int alexaClientSDK::avsCommon::utils::logger::MILLISECONDS_PER_SECOND = 1000
static

Number of milliseconds per second.

◆ PAIR_SEPARATOR

const char alexaClientSDK::avsCommon::utils::logger::PAIR_SEPARATOR = ','
static

Reserved in metadata sequences to separate key,value pairs.

◆ RESERVED_METADATA_CHARS

const char* alexaClientSDK::avsCommon::utils::logger::RESERVED_METADATA_CHARS = R"(\,=:)"
static

List of characters we need to escape.

◆ SECTION_SEPARATOR

const char alexaClientSDK::avsCommon::utils::logger::SECTION_SEPARATOR = ':'
static

Reserved in metadata sequences to separate them from a preceding event and an optional terminal message.

◆ STRFTIME_FORMAT_STRING

const char* alexaClientSDK::avsCommon::utils::logger::STRFTIME_FORMAT_STRING = "%Y-%m-%d %H:%M:%S"
static

Format string for strftime() to produce date and time in the format "YYYY-MM-DD HH:MM:SS".

◆ THREAD_AND_LEVEL_SEPARATOR

const std::string alexaClientSDK::avsCommon::utils::logger::THREAD_AND_LEVEL_SEPARATOR = "] "
static

Separator between thread ID and level indicator in log lines.

◆ TIME_AND_MILLIS_SEPARATOR

const char alexaClientSDK::avsCommon::utils::logger::TIME_AND_MILLIS_SEPARATOR = '.'
static

Separator between date/time and millis.

AlexaClientSDK 1.25.0 - Copyright 2016-2021 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0