AlexaClientSDK  3.0.0
A cross-platform, modular SDK for interacting with the Alexa Voice Service
Static Public Member Functions | Static Public Attributes | List of all members
alexaClientSDK::avsCommon::utils::logger::ThreadMoniker Class Reference

#include <ThreadMoniker.h>

Static Public Member Functions

static std::string getThisThreadMoniker () noexcept
 
static std::string generateMoniker (char prefix=0) noexcept
 
static void setThisThreadMoniker (const std::string &moniker) noexcept
 

Static Public Attributes

static constexpr char PREFIX_EXECUTOR = 'e'
 Prefix value for executor monikers. More...
 
static constexpr char PREFIX_TIMER = 't'
 Prefix value for timer monikers. More...
 

Detailed Description

Class to provide unique name for execution context.

This class provides management for thread-local execution context identifiers. Execution context identifier is a hexadecimal string which is managed by facilities like Executor and Timer. Logging framework adds identifier value to all messages to identify which executor or timer is running the task.

Note
The same identifier can be reused by different threads, but will have the same context.

Member Function Documentation

◆ generateMoniker()

static std::string alexaClientSDK::avsCommon::utils::logger::ThreadMoniker::generateMoniker ( char  prefix = 0)
staticnoexcept

Generate a unique moniker.

This method generates a fixed-width moniker string. By default the value is a alpha-numeric string, prepended with spaces. If the prefix is specified, the value also includes prefix character with colon.

Parameters
prefixOptional prefix for moniker value. If prefix if not 0, it is used for generating moniker. Some of prefix values are reserved for use by ACSDK: 't' prefix is used by timers, and 'e' prefix is used by executors.
Returns
A new unique moniker.

◆ getThisThreadMoniker()

static std::string alexaClientSDK::avsCommon::utils::logger::ThreadMoniker::getThisThreadMoniker ( )
staticnoexcept

Get the moniker for the caller's thread.

Method returns identifier value assigned to the current thread by a call to setThisThreadMoniker(). If the value has not been previously set, a new value is generated by generateMoniker(), assigned to the current thread, and returned.

Returns
The moniker for the caller's thread.

◆ setThisThreadMoniker()

static void alexaClientSDK::avsCommon::utils::logger::ThreadMoniker::setThisThreadMoniker ( const std::string &  moniker)
staticnoexcept

Set the moniker for the caller's thread.

This method sets identifier value for the caller's thread. Any subsequent calls to getThisThreadMoniker() will return moniker value.

Parameters
monikerThe moniker for std::this_thread.

Member Data Documentation

◆ PREFIX_EXECUTOR

constexpr char alexaClientSDK::avsCommon::utils::logger::ThreadMoniker::PREFIX_EXECUTOR = 'e'
static

Prefix value for executor monikers.

◆ PREFIX_TIMER

constexpr char alexaClientSDK::avsCommon::utils::logger::ThreadMoniker::PREFIX_TIMER = 't'
static

Prefix value for timer monikers.


The documentation for this class was generated from the following file:

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