Logger Class

Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control how or if the logged information is displayed or collected. See Learning about Logging.

Methods

Name Description
addActivityId(mdata: any): void Static Add the currently registered activityId, if any, to the specified metadata.
configureLevels(cfg: LoggerLevelsConfig): void Static Set the log level for multiple categories at once.
getLevel(category: string): LogLevel | undefined Static Get the minimum logging level for the specified category.
initialize(logError: LogFunction | undefined, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void Static Initialize the logger streams.
initializeToConsole(): void Static Initialize the logger streams to the console.
isEnabled(category: string, level: LogLevel): boolean Static Check if messages in the specified category should be displayed at this level of severity.
logError(category: string, message: string, metaData?: GetMetaDataFunction): void Static Log the specified message to the error stream.
logException(category: string, err: Error, log: LogFunction = Logger.logError, metaData?: GetMetaDataFunction): void Static Log the specified exception.
logInfo(category: string, message: string, metaData?: GetMetaDataFunction): void Static Log the specified message to the info stream.
logTrace(category: string, message: string, metaData?: GetMetaDataFunction): void Static Log the specified message to the trace stream.
logWarning(category: string, message: string, metaData?: GetMetaDataFunction): void Static Log the specified message to the warning stream.
Compose the metadata for a log message.
parseLogLevel(str: string): LogLevel Static Interpret a string as the name of a LogLevel
setLevel(category: string, minLevel: LogLevel): void Static Set the minimum logging level for the specified category.
setLevelDefault(minLevel: LogLevel): void Static Set the least severe level at which messages should be displayed by default.
turnOffCategories(): void Static Turns off all category level filters previously defined with Logger.setLevel.
turnOffLevelDefault(): void Static Turns off the least severe level at which messages should be displayed by default.
validateProps(config: any): void Static Check that the specified object is a valid LoggerLevelsConfig.

Properties

Name Type Description
logExceptionCallstacks Accessor Static boolean Should the callstack be included when an exception is logged?

Defined in

Last Updated: 06 December, 2018