Template Class LogManagerBase
Defined in File LogManagerBase.hpp
Class Documentation
-
template<class ModuleConfiguration>
class Microsoft::Applications::Events::LogManagerBase This class is used to manage the Events logging system
Public Types
-
using basetype = LogManagerBase<ModuleConfiguration>
Public Static Functions
-
static inline ILogConfiguration &GetLogConfiguration()
Returns this module LogConfiguration
-
static inline ILogger *Initialize()
Initializes the telemetry logging system with default configuration and HTTPClient.
- Returns
A logger instance instantiated with the default tenantToken.
-
static inline ILogger *Initialize(const std::string &tenantToken)
Initializes the telemetry logging system with the specified tenantToken.
- Parameters
tenantToken – Token of the tenant with which the application is associated for collecting telemetry
- Returns
A logger instance instantiated with the tenantToken.
-
static inline ILogger *Initialize(const std::string &tenantToken, ILogConfiguration &configuration)
Initializes the telemetry logging system with the specified ILogConfiguration.
- Parameters
tenantToken – Token of the tenant with which the application is associated for collecting telemetry
configuration – ILogConfiguration to be used.
- Returns
A logger instance instantiated with the tenantToken.
-
static inline status_t FlushAndTeardown()
Flush any pending telemetry events in memory to disk and tear down the telemetry logging system.
-
static inline status_t Flush()
Flush any pending telemetry events in memory to disk to reduce possible data loss as seen necessary.
This function can be very expensive so should be used sparingly. OS will block the calling thread and might flush the global file buffers, i.e. all buffered filesystem data, to disk, which could be time consuming.
-
static inline status_t PauseTransmission()
Pauses the transmission of events to data collector.
While pasued events will continue to be queued up on client side in cache (either in memory or on disk file).
-
static inline status_t SetTransmitProfile(TransmitProfile profile)
Sets transmit profile for event transmission to one of the built-in profiles.
A transmit profile is a collection of hardware and system settings (like network connectivity, power state) based on which to determine how events are to be transmitted.
- Parameters
profile – Transmit profile
- Returns
This function doesn’t return any value because it always succeeds.
-
static inline status_t SetTransmitProfile(const std::string &profile)
Sets transmit profile for event transmission.
A transmit profile is a collection of hardware and system settings (like network connectivity, power state) based on which to determine how events are to be transmitted.
- Parameters
profile – Transmit profile
- Returns
true if profile is successfully applied, false otherwise
-
static inline status_t LoadTransmitProfiles(const std::string &profiles_json)
Load transmit profiles from JSON config
- Parameters
profiles_json – JSON config (see example above)
- Returns
true on successful profiles load, false if config is invalid
-
static inline std::string GetTransmitProfileName()
Get profile name based on built-in profile enum
- Parameters
profile – Transmit profile
-
static inline ISemanticContext *GetSemanticContext()
Retrieve an ISemanticContext interface through which to specify context information such as device, system, hardware and user information.
Context information set via this API will apply to all logger instance unless they are overwritten by individual logger instance.
- Returns
ISemanticContext interface pointer
-
static inline status_t SetContext(const std::string &name, const std::string &value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the custom context for the telemetry logging system.
Context information set here applies to events generated by all ILogger instances unless it is overwritten on a particular ILogger instance.
- Parameters
name – Name of the context property
value – Value of the context property
piiKind – PIIKind of the context with PiiKind_None as the default
-
static inline status_t SetContext(const std::string &name, const char *value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the custom context for the telemetry logging system.
Context information set here applies to events generated by all ILogger instances unless it is overwritten on a particular ILogger instance.
- Parameters
name – Name of the context property
value – Value of the context property
piiKind – PIIKind of the context with PiiKind_None as the default
-
static inline status_t SetContext(const std::string &name, double value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
- Parameters
name – Name of the property
value – Double value of the property
-
static inline status_t SetContext(const std::string &name, int64_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
- Parameters
name – Name of the property
value – 64-bit Integer value of the property
-
static inline status_t SetContext(const std::string &name, int8_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
All integer types other than int64_t are currently being converted to int64_t
- Parameters
name – Name of the property
value – 8-bit Integer value of the property
-
static inline status_t SetContext(const std::string &name, int16_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
All integer types other than int64_t are currently being converted to int64_t
- Parameters
name – Name of the property
value – 16-bit Integer value of the property
-
static inline status_t SetContext(const std::string &name, int32_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
All integer types other than int64_t are currently being converted to int64_t
- Parameters
name – Name of the property
value – 32-bit Integer value of the property
-
static inline status_t SetContext(const std::string &name, uint8_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
All integer types other than int64_t are currently being converted to int64_t
- Parameters
name – Name of the property
value – 8-bit unsigned integer value of the property
-
static inline status_t SetContext(const std::string &name, uint16_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
All integer types other than int64_t are currently being converted to int64_t
- Parameters
name – Name of the property
value – 16-bit unsigned integer value of the property
-
static inline status_t SetContext(const std::string &name, uint32_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
All integer types other than int64_t are currently being converted to int64_t
- Parameters
name – Name of the property
value – 32-bit unsigned integer value of the property
-
static inline status_t SetContext(const std::string &name, uint64_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
All integer types other than int64_t are currently being converted to int64_t
- Parameters
name – Name of the property
value – 64-bit unsigned integer value of the property
-
static inline status_t SetContext(const std::string &name, bool value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
- Parameters
name – Name of the property
value – Boolean value of the property
-
static inline status_t SetContext(const std::string &name, time_ticks_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
- Parameters
name – Name of the property
value – .NET time ticks
-
static inline status_t SetContext(const std::string &name, GUID_t value, PiiKind piiKind = PiiKind_None)
Adds or overrides a property of the global context.
- Parameters
name – Name of the property
value – GUID
-
static inline ILogger *GetLogger()
Retrieves the ILogger interface of a Logger instance through which to log telemetry event.
- Returns
Pointer to the Ilogger interface of an logger instance
-
static inline ILogger *GetLogger(const std::string &source)
Retrieves the ILogger interface of a Logger instance through which to log telemetry event.
- Parameters
source – Source name of events sent by this logger instance
- Returns
Pointer to the Ilogger interface of the logger instance
-
static inline ILogger *GetLogger(const std::string &tenantToken, const std::string &source)
Retrieves the ILogger interface of a Logger instance through which to log telemetry event.
- Parameters
tenantToken – Token of the tenant with which the application is associated for collecting telemetry
source – Source name of events sent by this logger instance
- Returns
Pointer to the Ilogger interface of the logger instance
-
static inline IAuthTokensController *GetAuthTokensController()
Get Auth token controller
-
static inline IEventFilterCollection &GetEventFilters()
Obtain event filter collection.
Notes:
If the build has exceptions enabled, then the code triggers exception in case of invalid API use.
If the build has exceptions disabled, then the code returns an empty NULL object pattern collection.
-
static inline void AddEventListener(DebugEventType type, DebugEventListener &listener)
Add Debug callback
-
static inline void RemoveEventListener(DebugEventType type, DebugEventListener &listener)
Remove Debug callback
-
static inline bool DispatchEvent(DebugEventType type)
Dispatches a debug event of the specified type.
- Parameters
type – One of the DebugEventType enumeration types.
-
static inline bool DispatchEvent(DebugEvent evt)
Dispatches the specified event to a client callback.
- Parameters
evt – A reference to a DebugEvent object.
-
static inline LogSessionData *GetLogSessionData()
Gets the log session data.
- Returns
The log session data in a pointer to a LogSessionData object.
-
static inline void SetLevelFilter(uint8_t defaultLevel, uint8_t levelMin, uint8_t levelMax)
Sets the diagnostic level filter for the LogManager
- Parameters
defaultLevel – Diagnostic level for the LogManager
levelMin – Minimum level to be sent
levelMin – Maximum level to be sent
-
static inline void SetLevelFilter(uint8_t defaultLevel, const std::set<uint8_t> &allowedLevels)
Sets the diagnostic level filter for the LogManager
- Parameters
defaultLevel – Diagnostic level for the LogManager
allowedLevels – Set with levels that are allowed to be sent
-
static inline ILogController *GetController()
-
static inline status_t Configure()
Reconfigure the log manager instance.
Reserved for future use to notify SDK about ILogConfiguration & contents change.
-
static inline IDataViewerCollection &GetDataViewerCollection()
Obtain data viewer collection associated with this LogManager instance.
-
static inline void PauseActivity()
-
static inline void ResumeActivity()
-
static inline void WaitPause()
-
static inline bool StartActivity()
-
static inline void EndActivity()
-
static inline ILogManager *GetInstance() noexcept
Obtain a raw pointer to the ILogManager singleton instance.
NOTE: this API should not be used concurrently with Initialize or FlushAndTeardown API calls.
Protected Functions
-
inline LogManagerBase()
LogManagerBase constructor
-
inline LogManagerBase(const LogManagerBase&)
LogManager copy constructor
-
inline LogManagerBase &operator=(const LogManagerBase&)
[not implemented] LogManager assignment operator
-
inline virtual ~LogManagerBase()
LogManager destructor
Protected Static Functions
-
static inline std::recursive_mutex &stateLock()
Native code lock used for executing singleton state-management methods in a thread-safe manner.
Managed code uses a different LogManagerLock.
-
static inline bool isHost()
-
static inline DebugEventSource &GetDebugEventSource()
Debug event source associated with this singleton
-
static inline const char *GetPrimaryToken()
Protected Static Attributes
-
static ILogManager *instance
Concrete instance for servicing all singleton calls
-
using basetype = LogManagerBase<ModuleConfiguration>