@itwin/core-bentley 4.9.0-dev.9 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -1
- package/lib/cjs/Logger.d.ts.map +1 -1
- package/lib/cjs/Logger.js +7 -1
- package/lib/cjs/Logger.js.map +1 -1
- package/lib/esm/Logger.d.ts.map +1 -1
- package/lib/esm/Logger.js +7 -1
- package/lib/esm/Logger.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
1
|
# Change Log - @itwin/core-bentley
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Mon, 23 Sep 2024 13:44:01 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.9.0
|
|
6
|
+
Mon, 23 Sep 2024 13:44:01 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 4.8.7
|
|
11
|
+
Fri, 13 Sep 2024 15:11:17 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 4.8.6
|
|
16
|
+
Fri, 06 Sep 2024 05:06:49 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 4.8.5
|
|
21
|
+
Wed, 28 Aug 2024 17:27:23 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
25
|
+
## 4.8.4
|
|
26
|
+
Thu, 22 Aug 2024 17:37:06 GMT
|
|
27
|
+
|
|
28
|
+
_Version update only_
|
|
29
|
+
|
|
30
|
+
## 4.8.3
|
|
31
|
+
Fri, 16 Aug 2024 18:18:14 GMT
|
|
32
|
+
|
|
33
|
+
_Version update only_
|
|
4
34
|
|
|
5
35
|
## 4.8.2
|
|
6
36
|
Thu, 15 Aug 2024 15:33:49 GMT
|
package/lib/cjs/Logger.d.ts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AAI;CAGvB"}
|
package/lib/cjs/Logger.js
CHANGED
|
@@ -189,6 +189,12 @@ class Logger {
|
|
|
189
189
|
Logger._logError(category, message, metaData);
|
|
190
190
|
}
|
|
191
191
|
static getExceptionMessage(err) {
|
|
192
|
+
if (err === undefined) {
|
|
193
|
+
return "Error: err is undefined.";
|
|
194
|
+
}
|
|
195
|
+
if (err === null) {
|
|
196
|
+
return "Error: err is null.";
|
|
197
|
+
}
|
|
192
198
|
const stack = Logger.logExceptionCallstacks ? `\n${BentleyError_1.BentleyError.getErrorStack(err)}` : "";
|
|
193
199
|
return BentleyError_1.BentleyError.getErrorMessage(err) + stack;
|
|
194
200
|
}
|
|
@@ -199,7 +205,7 @@ class Logger {
|
|
|
199
205
|
*/
|
|
200
206
|
static logException(category, err, log = (_category, message, metaData) => Logger.logError(_category, message, metaData)) {
|
|
201
207
|
log(category, Logger.getExceptionMessage(err), () => {
|
|
202
|
-
return { ...BentleyError_1.BentleyError.getErrorMetadata(err), exceptionType: err
|
|
208
|
+
return { ...BentleyError_1.BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? "<Unknown>" };
|
|
203
209
|
});
|
|
204
210
|
}
|
|
205
211
|
/** Log the specified message to the **warning** stream.
|
package/lib/cjs/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AACpC,iDAA6E;AAC7E,mEAAgE;AAEhE,0EAAuE;AAOvE;;GAEG;AACH,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA;IACJ,4BAA4B;IAC5B,6CAAO,CAAA;IACP,6BAA6B;IAC7B,yCAAK,CAAA;IACL,+EAA+E;IAC/E,uCAAI,CAAA;AACN,CAAC,EAXW,QAAQ,wBAAR,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AAE;YAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,2BAAY,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO;gBACL,GAAG,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,2DAA2D;aACxH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;;AAnCH,gCAoCC;AAnCgB,oBAAS,GAAa,QAAQ,CAAC,IAAI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Logging\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\r\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\r\nimport { IDisposable } from \"./Disposable\";\r\nimport { staticLoggerMetadata } from \"./internal/staticLoggerMetadata\";\r\n\r\n/** Defines the *signature* for a log function.\r\n * @public\r\n */\r\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\r\n\r\n/** Use to categorize logging messages by severity.\r\n * @public\r\n */\r\nexport enum LogLevel {\r\n /** Tracing and debugging - low level */\r\n Trace,\r\n /** Information - mid level */\r\n Info,\r\n /** Warnings - high level */\r\n Warning,\r\n /** Errors - highest level */\r\n Error,\r\n /** Higher than any real logging level. This is used to turn a category off. */\r\n None,\r\n}\r\n\r\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\r\n * @public\r\n */\r\nexport interface LoggerCategoryAndLevel {\r\n category: string;\r\n logLevel: string;\r\n}\r\n\r\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\r\n * @public\r\n */\r\nexport interface LoggerLevelsConfig {\r\n defaultLevel?: string;\r\n categoryLevels?: LoggerCategoryAndLevel[];\r\n}\r\n\r\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\r\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\r\n * @public\r\n */\r\nexport class Logger {\r\n protected static _logError: LogFunction | undefined;\r\n protected static _logWarning: LogFunction | undefined;\r\n protected static _logInfo: LogFunction | undefined;\r\n protected static _logTrace: LogFunction | undefined;\r\n\r\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\r\n\r\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\r\n public static get onLogLevelChanged(): BeEvent<() => void> {\r\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\r\n if (undefined === Logger._onLogLevelChanged) {\r\n Logger._onLogLevelChanged = new BeEvent<() => void>();\r\n }\r\n\r\n return Logger._onLogLevelChanged;\r\n }\r\n\r\n private static _categoryFilter: {[categoryName: string]: LogLevel | undefined} = {};\r\n\r\n /** Maps category names to the least severe level at which messages in that category should be displayed,\r\n * or `undefined` if a minimum has not been defined.\r\n * @see [[setLevel]] to change the minimum logging level for a category.\r\n */\r\n public static get categoryFilter(): Readonly<{[categoryName: string]: LogLevel | undefined}> {\r\n // NOTE: this property is accessed by native code.\r\n return this._categoryFilter;\r\n }\r\n\r\n private static _minLevel: LogLevel | undefined;\r\n\r\n /** The least severe level at which messages should be displayed by default.\r\n * @see [[setLevelDefault]] to change this default.\r\n * @see [[setLevel]] to override this default for specific categories.\r\n */\r\n public static get minLevel(): LogLevel | undefined {\r\n // NOTE: this property is accessed by native code. */\r\n return this._minLevel;\r\n }\r\n\r\n /** Should the call stack be included when an exception is logged? */\r\n public static logExceptionCallstacks = false;\r\n\r\n /** Initialize the logger streams. Should be called at application initialization time. */\r\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\r\n Logger._logError = logError;\r\n Logger._logWarning = logWarning;\r\n Logger._logInfo = logInfo;\r\n Logger._logTrace = logTrace;\r\n Logger.turnOffLevelDefault();\r\n Logger.turnOffCategories();\r\n }\r\n\r\n /** Initialize the logger to output to the console. */\r\n public static initializeToConsole(): void {\r\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\r\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\r\n\r\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\r\n }\r\n\r\n /** merge the supplied metadata with all static metadata into one object */\r\n public static getMetaData(metaData?: LoggingMetaData): object {\r\n const metaObj = {};\r\n for (const meta of staticLoggerMetadata) {\r\n const val = BentleyError.getMetaData(meta[1]);\r\n if (val)\r\n Object.assign(metaObj, val);\r\n }\r\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\r\n return metaObj;\r\n }\r\n\r\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\r\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\r\n const metaObj = this.getMetaData(metaData);\r\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\r\n }\r\n\r\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\r\n public static setLevelDefault(minLevel: LogLevel): void {\r\n this._minLevel = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\r\n * specified category should be displayed.\r\n */\r\n public static setLevel(category: string, minLevel: LogLevel) {\r\n Logger._categoryFilter[category] = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Interpret a string as the name of a LogLevel */\r\n public static parseLogLevel(str: string): LogLevel {\r\n switch (str.toUpperCase()) {\r\n case \"EXCEPTION\": return LogLevel.Error;\r\n case \"FATAL\": return LogLevel.Error;\r\n case \"ERROR\": return LogLevel.Error;\r\n case \"WARNING\": return LogLevel.Warning;\r\n case \"INFO\": return LogLevel.Info;\r\n case \"TRACE\": return LogLevel.Trace;\r\n case \"DEBUG\": return LogLevel.Trace;\r\n }\r\n return LogLevel.None;\r\n }\r\n\r\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\r\n public static configureLevels(cfg: LoggerLevelsConfig) {\r\n Logger.validateProps(cfg);\r\n if (cfg.defaultLevel !== undefined) {\r\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\r\n }\r\n if (cfg.categoryLevels !== undefined) {\r\n for (const cl of cfg.categoryLevels) {\r\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\r\n }\r\n }\r\n }\r\n\r\n private static isLogLevel(v: string) {\r\n return LogLevel.hasOwnProperty(v);\r\n }\r\n\r\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\r\n public static validateProps(config: any) {\r\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\r\n for (const prop of Object.keys(config)) {\r\n if (!validProps.includes(prop))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\r\n if (prop === \"defaultLevel\") {\r\n if (!Logger.isLogLevel(config.defaultLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\r\n } else if (prop === \"categoryLevels\") {\r\n const value = config[prop];\r\n if (!Array.isArray(value))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\r\n for (const item of config[prop]) {\r\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\r\n if (!Logger.isLogLevel(item.logLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Get the minimum logging level for the specified category. */\r\n public static getLevel(category: string): LogLevel | undefined {\r\n // Prefer the level set for this category specifically\r\n const minLevelForThisCategory = Logger.categoryFilter[category];\r\n if (minLevelForThisCategory !== undefined)\r\n return minLevelForThisCategory;\r\n\r\n // Fall back on the level set for the parent of this category.\r\n const parent = category.lastIndexOf(\".\");\r\n if (parent !== -1)\r\n return Logger.getLevel(category.slice(0, parent));\r\n\r\n // Fall back on the default level.\r\n return Logger.minLevel;\r\n }\r\n\r\n /** Turns off the least severe level at which messages should be displayed by default.\r\n * This turns off logging for all messages for which no category minimum level is defined.\r\n */\r\n public static turnOffLevelDefault(): void {\r\n Logger._minLevel = undefined;\r\n }\r\n\r\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\r\n */\r\n public static turnOffCategories(): void {\r\n Logger._categoryFilter = {};\r\n }\r\n\r\n /** Check if messages in the specified category should be displayed at this level of severity. */\r\n public static isEnabled(category: string, level: LogLevel): boolean {\r\n const minLevel = Logger.getLevel(category);\r\n return (minLevel !== undefined) && (level >= minLevel);\r\n }\r\n\r\n /** Log the specified message to the **error** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\r\n Logger._logError(category, message, metaData);\r\n }\r\n\r\n private static getExceptionMessage(err: unknown): string {\r\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\r\n return BentleyError.getErrorMessage(err) + stack;\r\n }\r\n\r\n /** Log the specified exception. The special \"ExceptionType\" property will be added as metadata.\r\n * @param category The category of the message.\r\n * @param err The exception object.\r\n * @param log The logger output function to use - defaults to Logger.logError\r\n */\r\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\r\n log(category, Logger.getExceptionMessage(err), () => {\r\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err.constructor.name };\r\n });\r\n }\r\n\r\n /** Log the specified message to the **warning** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\r\n Logger._logWarning(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **info** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\r\n Logger._logInfo(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **trace** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\r\n Logger._logTrace(category, message, metaData);\r\n }\r\n}\r\n\r\n/** Simple performance diagnostics utility.\r\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\r\n * the duration in milliseconds.\r\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\r\n *\r\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\r\n * Enable those, if you want to capture timings.\r\n * @public\r\n */\r\nexport class PerfLogger implements IDisposable {\r\n private static _severity: LogLevel = LogLevel.Info;\r\n\r\n private _operation: string;\r\n private _metaData?: LoggingMetaData;\r\n private _startTimeStamp: number;\r\n\r\n public constructor(operation: string, metaData?: LoggingMetaData) {\r\n this._operation = operation;\r\n this._metaData = metaData;\r\n\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\r\n this._startTimeStamp = 0;\r\n return;\r\n }\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\r\n this._startTimeStamp = new Date().getTime(); // take timestamp\r\n }\r\n\r\n private logMessage(): void {\r\n const endTimeStamp: number = new Date().getTime();\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\r\n return;\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\r\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\r\n return {\r\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n });\r\n }\r\n\r\n public dispose(): void {\r\n this.logMessage();\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AACpC,iDAA6E;AAC7E,mEAAgE;AAEhE,0EAAuE;AAOvE;;GAEG;AACH,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA;IACJ,4BAA4B;IAC5B,6CAAO,CAAA;IACP,6BAA6B;IAC7B,yCAAK,CAAA;IACL,+EAA+E;IAC/E,uCAAI,CAAA;AACN,CAAC,EAXW,QAAQ,wBAAR,QAAQ,QAWnB;AAkBD;;;GAGG;AACH,MAAa,MAAM;IAQjB,8EAA8E;IACvE,MAAM,KAAK,iBAAiB;QACjC,iJAAiJ;QACjJ,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC5C,MAAM,CAAC,kBAAkB,GAAG,IAAI,iBAAO,EAAc,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AAS,CAAC,CAAC,CAAC,2BAAY,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO;gBACL,GAAG,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,2DAA2D;aACxH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;;AAnCH,gCAoCC;AAnCgB,oBAAS,GAAa,QAAQ,CAAC,IAAI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Logging\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\r\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\r\nimport { IDisposable } from \"./Disposable\";\r\nimport { staticLoggerMetadata } from \"./internal/staticLoggerMetadata\";\r\n\r\n/** Defines the *signature* for a log function.\r\n * @public\r\n */\r\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\r\n\r\n/** Use to categorize logging messages by severity.\r\n * @public\r\n */\r\nexport enum LogLevel {\r\n /** Tracing and debugging - low level */\r\n Trace,\r\n /** Information - mid level */\r\n Info,\r\n /** Warnings - high level */\r\n Warning,\r\n /** Errors - highest level */\r\n Error,\r\n /** Higher than any real logging level. This is used to turn a category off. */\r\n None,\r\n}\r\n\r\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\r\n * @public\r\n */\r\nexport interface LoggerCategoryAndLevel {\r\n category: string;\r\n logLevel: string;\r\n}\r\n\r\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\r\n * @public\r\n */\r\nexport interface LoggerLevelsConfig {\r\n defaultLevel?: string;\r\n categoryLevels?: LoggerCategoryAndLevel[];\r\n}\r\n\r\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\r\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\r\n * @public\r\n */\r\nexport class Logger {\r\n protected static _logError: LogFunction | undefined;\r\n protected static _logWarning: LogFunction | undefined;\r\n protected static _logInfo: LogFunction | undefined;\r\n protected static _logTrace: LogFunction | undefined;\r\n\r\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\r\n\r\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\r\n public static get onLogLevelChanged(): BeEvent<() => void> {\r\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\r\n if (undefined === Logger._onLogLevelChanged) {\r\n Logger._onLogLevelChanged = new BeEvent<() => void>();\r\n }\r\n\r\n return Logger._onLogLevelChanged;\r\n }\r\n\r\n private static _categoryFilter: {[categoryName: string]: LogLevel | undefined} = {};\r\n\r\n /** Maps category names to the least severe level at which messages in that category should be displayed,\r\n * or `undefined` if a minimum has not been defined.\r\n * @see [[setLevel]] to change the minimum logging level for a category.\r\n */\r\n public static get categoryFilter(): Readonly<{[categoryName: string]: LogLevel | undefined}> {\r\n // NOTE: this property is accessed by native code.\r\n return this._categoryFilter;\r\n }\r\n\r\n private static _minLevel: LogLevel | undefined;\r\n\r\n /** The least severe level at which messages should be displayed by default.\r\n * @see [[setLevelDefault]] to change this default.\r\n * @see [[setLevel]] to override this default for specific categories.\r\n */\r\n public static get minLevel(): LogLevel | undefined {\r\n // NOTE: this property is accessed by native code. */\r\n return this._minLevel;\r\n }\r\n\r\n /** Should the call stack be included when an exception is logged? */\r\n public static logExceptionCallstacks = false;\r\n\r\n /** Initialize the logger streams. Should be called at application initialization time. */\r\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\r\n Logger._logError = logError;\r\n Logger._logWarning = logWarning;\r\n Logger._logInfo = logInfo;\r\n Logger._logTrace = logTrace;\r\n Logger.turnOffLevelDefault();\r\n Logger.turnOffCategories();\r\n }\r\n\r\n /** Initialize the logger to output to the console. */\r\n public static initializeToConsole(): void {\r\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\r\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\r\n\r\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\r\n }\r\n\r\n /** merge the supplied metadata with all static metadata into one object */\r\n public static getMetaData(metaData?: LoggingMetaData): object {\r\n const metaObj = {};\r\n for (const meta of staticLoggerMetadata) {\r\n const val = BentleyError.getMetaData(meta[1]);\r\n if (val)\r\n Object.assign(metaObj, val);\r\n }\r\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\r\n return metaObj;\r\n }\r\n\r\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\r\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\r\n const metaObj = this.getMetaData(metaData);\r\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\r\n }\r\n\r\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\r\n public static setLevelDefault(minLevel: LogLevel): void {\r\n this._minLevel = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\r\n * specified category should be displayed.\r\n */\r\n public static setLevel(category: string, minLevel: LogLevel) {\r\n Logger._categoryFilter[category] = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Interpret a string as the name of a LogLevel */\r\n public static parseLogLevel(str: string): LogLevel {\r\n switch (str.toUpperCase()) {\r\n case \"EXCEPTION\": return LogLevel.Error;\r\n case \"FATAL\": return LogLevel.Error;\r\n case \"ERROR\": return LogLevel.Error;\r\n case \"WARNING\": return LogLevel.Warning;\r\n case \"INFO\": return LogLevel.Info;\r\n case \"TRACE\": return LogLevel.Trace;\r\n case \"DEBUG\": return LogLevel.Trace;\r\n }\r\n return LogLevel.None;\r\n }\r\n\r\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\r\n public static configureLevels(cfg: LoggerLevelsConfig) {\r\n Logger.validateProps(cfg);\r\n if (cfg.defaultLevel !== undefined) {\r\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\r\n }\r\n if (cfg.categoryLevels !== undefined) {\r\n for (const cl of cfg.categoryLevels) {\r\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\r\n }\r\n }\r\n }\r\n\r\n private static isLogLevel(v: string) {\r\n return LogLevel.hasOwnProperty(v);\r\n }\r\n\r\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\r\n public static validateProps(config: any) {\r\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\r\n for (const prop of Object.keys(config)) {\r\n if (!validProps.includes(prop))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\r\n if (prop === \"defaultLevel\") {\r\n if (!Logger.isLogLevel(config.defaultLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\r\n } else if (prop === \"categoryLevels\") {\r\n const value = config[prop];\r\n if (!Array.isArray(value))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\r\n for (const item of config[prop]) {\r\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\r\n if (!Logger.isLogLevel(item.logLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Get the minimum logging level for the specified category. */\r\n public static getLevel(category: string): LogLevel | undefined {\r\n // Prefer the level set for this category specifically\r\n const minLevelForThisCategory = Logger.categoryFilter[category];\r\n if (minLevelForThisCategory !== undefined)\r\n return minLevelForThisCategory;\r\n\r\n // Fall back on the level set for the parent of this category.\r\n const parent = category.lastIndexOf(\".\");\r\n if (parent !== -1)\r\n return Logger.getLevel(category.slice(0, parent));\r\n\r\n // Fall back on the default level.\r\n return Logger.minLevel;\r\n }\r\n\r\n /** Turns off the least severe level at which messages should be displayed by default.\r\n * This turns off logging for all messages for which no category minimum level is defined.\r\n */\r\n public static turnOffLevelDefault(): void {\r\n Logger._minLevel = undefined;\r\n }\r\n\r\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\r\n */\r\n public static turnOffCategories(): void {\r\n Logger._categoryFilter = {};\r\n }\r\n\r\n /** Check if messages in the specified category should be displayed at this level of severity. */\r\n public static isEnabled(category: string, level: LogLevel): boolean {\r\n const minLevel = Logger.getLevel(category);\r\n return (minLevel !== undefined) && (level >= minLevel);\r\n }\r\n\r\n /** Log the specified message to the **error** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\r\n Logger._logError(category, message, metaData);\r\n }\r\n\r\n private static getExceptionMessage(err: unknown): string {\r\n if (err === undefined) {\r\n return \"Error: err is undefined.\";\r\n }\r\n if (err === null) {\r\n return \"Error: err is null.\";\r\n }\r\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\r\n return BentleyError.getErrorMessage(err) + stack;\r\n }\r\n\r\n /** Log the specified exception. The special \"ExceptionType\" property will be added as metadata.\r\n * @param category The category of the message.\r\n * @param err The exception object.\r\n * @param log The logger output function to use - defaults to Logger.logError\r\n */\r\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\r\n log(category, Logger.getExceptionMessage(err), () => {\r\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\"};\r\n });\r\n }\r\n\r\n /** Log the specified message to the **warning** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\r\n Logger._logWarning(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **info** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\r\n Logger._logInfo(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **trace** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\r\n Logger._logTrace(category, message, metaData);\r\n }\r\n}\r\n\r\n/** Simple performance diagnostics utility.\r\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\r\n * the duration in milliseconds.\r\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\r\n *\r\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\r\n * Enable those, if you want to capture timings.\r\n * @public\r\n */\r\nexport class PerfLogger implements IDisposable {\r\n private static _severity: LogLevel = LogLevel.Info;\r\n\r\n private _operation: string;\r\n private _metaData?: LoggingMetaData;\r\n private _startTimeStamp: number;\r\n\r\n public constructor(operation: string, metaData?: LoggingMetaData) {\r\n this._operation = operation;\r\n this._metaData = metaData;\r\n\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\r\n this._startTimeStamp = 0;\r\n return;\r\n }\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\r\n this._startTimeStamp = new Date().getTime(); // take timestamp\r\n }\r\n\r\n private logMessage(): void {\r\n const endTimeStamp: number = new Date().getTime();\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\r\n return;\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\r\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\r\n return {\r\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n });\r\n }\r\n\r\n public dispose(): void {\r\n this.logMessage();\r\n }\r\n}\r\n\r\n"]}
|
package/lib/esm/Logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAA8B,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE7E,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;AAEjG;;GAEG;AACH,oBAAY,QAAQ;IAClB,wCAAwC;IACxC,KAAK,IAAA;IACL,8BAA8B;IAC9B,IAAI,IAAA;IACJ,4BAA4B;IAC5B,OAAO,IAAA;IACP,6BAA6B;IAC7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GAAG,IAAI;IAMhK;;;;OAIG;WACW,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI;IAK7F;;;;OAIG;WACW,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI;IAK1F;;;;OAIG;WACW,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI;CAI5F;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAW,YAAW,WAAW;IAC5C,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;IAEnD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAC,CAAkB;IACpC,OAAO,CAAC,eAAe,CAAS;gBAEb,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe;IAahE,OAAO,CAAC,UAAU;IAaX,OAAO,IAAI,IAAI;CAGvB"}
|
package/lib/esm/Logger.js
CHANGED
|
@@ -186,6 +186,12 @@ export class Logger {
|
|
|
186
186
|
Logger._logError(category, message, metaData);
|
|
187
187
|
}
|
|
188
188
|
static getExceptionMessage(err) {
|
|
189
|
+
if (err === undefined) {
|
|
190
|
+
return "Error: err is undefined.";
|
|
191
|
+
}
|
|
192
|
+
if (err === null) {
|
|
193
|
+
return "Error: err is null.";
|
|
194
|
+
}
|
|
189
195
|
const stack = Logger.logExceptionCallstacks ? `\n${BentleyError.getErrorStack(err)}` : "";
|
|
190
196
|
return BentleyError.getErrorMessage(err) + stack;
|
|
191
197
|
}
|
|
@@ -196,7 +202,7 @@ export class Logger {
|
|
|
196
202
|
*/
|
|
197
203
|
static logException(category, err, log = (_category, message, metaData) => Logger.logError(_category, message, metaData)) {
|
|
198
204
|
log(category, Logger.getExceptionMessage(err), () => {
|
|
199
|
-
return { ...BentleyError.getErrorMetadata(err), exceptionType: err
|
|
205
|
+
return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? "<Unknown>" };
|
|
200
206
|
});
|
|
201
207
|
}
|
|
202
208
|
/** Log the specified message to the **warning** stream.
|
package/lib/esm/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAOvE;;GAEG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA;IACJ,4BAA4B;IAC5B,6CAAO,CAAA;IACP,6BAA6B;IAC7B,yCAAK,CAAA;IACL,+EAA+E;IAC/E,uCAAI,CAAA;AACN,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAkBD;;;GAGG;AACH,MAAM,OAAO,MAAM;IAQjB,8EAA8E;IACvE,MAAM,KAAK,iBAAiB;QACjC,iJAAiJ;QACjJ,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC5C,MAAM,CAAC,kBAAkB,GAAG,IAAI,OAAO,EAAc,CAAC;QACxD,CAAC;QAED,OAAO,MAAM,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAID;;;OAGG;IACI,MAAM,KAAK,cAAc;QAC9B,kDAAkD;QAClD,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAID;;;OAGG;IACI,MAAM,KAAK,QAAQ;Q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iB,EAAE,QAA0B;QAC9D,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAE1B,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/E,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;YACzB,OAAO;QACT,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9F,IAAI,CAAC,eAAe,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,iBAAiB;IAChE,CAAC;IAEO,UAAU;QAChB,MAAM,YAAY,GAAW,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,qBAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC;YAC5E,OAAO;QAET,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,MAAM,EAAE,GAAG,EAAE;YAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO;gBACL,GAAG,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,2DAA2D;aACxH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;;AAlCc,oBAAS,GAAa,QAAQ,CAAC,IAAI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Logging\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\r\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\r\nimport { IDisposable } from \"./Disposable\";\r\nimport { staticLoggerMetadata } from \"./internal/staticLoggerMetadata\";\r\n\r\n/** Defines the *signature* for a log function.\r\n * @public\r\n */\r\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\r\n\r\n/** Use to categorize logging messages by severity.\r\n * @public\r\n */\r\nexport enum LogLevel {\r\n /** Tracing and debugging - low level */\r\n Trace,\r\n /** Information - mid level */\r\n Info,\r\n /** Warnings - high level */\r\n Warning,\r\n /** Errors - highest level */\r\n Error,\r\n /** Higher than any real logging level. This is used to turn a category off. */\r\n None,\r\n}\r\n\r\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\r\n * @public\r\n */\r\nexport interface LoggerCategoryAndLevel {\r\n category: string;\r\n logLevel: string;\r\n}\r\n\r\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\r\n * @public\r\n */\r\nexport interface LoggerLevelsConfig {\r\n defaultLevel?: string;\r\n categoryLevels?: LoggerCategoryAndLevel[];\r\n}\r\n\r\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\r\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\r\n * @public\r\n */\r\nexport class Logger {\r\n protected static _logError: LogFunction | undefined;\r\n protected static _logWarning: LogFunction | undefined;\r\n protected static _logInfo: LogFunction | undefined;\r\n protected static _logTrace: LogFunction | undefined;\r\n\r\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\r\n\r\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\r\n public static get onLogLevelChanged(): BeEvent<() => void> {\r\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\r\n if (undefined === Logger._onLogLevelChanged) {\r\n Logger._onLogLevelChanged = new BeEvent<() => void>();\r\n }\r\n\r\n return Logger._onLogLevelChanged;\r\n }\r\n\r\n private static _categoryFilter: {[categoryName: string]: LogLevel | undefined} = {};\r\n\r\n /** Maps category names to the least severe level at which messages in that category should be displayed,\r\n * or `undefined` if a minimum has not been defined.\r\n * @see [[setLevel]] to change the minimum logging level for a category.\r\n */\r\n public static get categoryFilter(): Readonly<{[categoryName: string]: LogLevel | undefined}> {\r\n // NOTE: this property is accessed by native code.\r\n return this._categoryFilter;\r\n }\r\n\r\n private static _minLevel: LogLevel | undefined;\r\n\r\n /** The least severe level at which messages should be displayed by default.\r\n * @see [[setLevelDefault]] to change this default.\r\n * @see [[setLevel]] to override this default for specific categories.\r\n */\r\n public static get minLevel(): LogLevel | undefined {\r\n // NOTE: this property is accessed by native code. */\r\n return this._minLevel;\r\n }\r\n\r\n /** Should the call stack be included when an exception is logged? */\r\n public static logExceptionCallstacks = false;\r\n\r\n /** Initialize the logger streams. Should be called at application initialization time. */\r\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\r\n Logger._logError = logError;\r\n Logger._logWarning = logWarning;\r\n Logger._logInfo = logInfo;\r\n Logger._logTrace = logTrace;\r\n Logger.turnOffLevelDefault();\r\n Logger.turnOffCategories();\r\n }\r\n\r\n /** Initialize the logger to output to the console. */\r\n public static initializeToConsole(): void {\r\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\r\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\r\n\r\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\r\n }\r\n\r\n /** merge the supplied metadata with all static metadata into one object */\r\n public static getMetaData(metaData?: LoggingMetaData): object {\r\n const metaObj = {};\r\n for (const meta of staticLoggerMetadata) {\r\n const val = BentleyError.getMetaData(meta[1]);\r\n if (val)\r\n Object.assign(metaObj, val);\r\n }\r\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\r\n return metaObj;\r\n }\r\n\r\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\r\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\r\n const metaObj = this.getMetaData(metaData);\r\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\r\n }\r\n\r\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\r\n public static setLevelDefault(minLevel: LogLevel): void {\r\n this._minLevel = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\r\n * specified category should be displayed.\r\n */\r\n public static setLevel(category: string, minLevel: LogLevel) {\r\n Logger._categoryFilter[category] = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Interpret a string as the name of a LogLevel */\r\n public static parseLogLevel(str: string): LogLevel {\r\n switch (str.toUpperCase()) {\r\n case \"EXCEPTION\": return LogLevel.Error;\r\n case \"FATAL\": return LogLevel.Error;\r\n case \"ERROR\": return LogLevel.Error;\r\n case \"WARNING\": return LogLevel.Warning;\r\n case \"INFO\": return LogLevel.Info;\r\n case \"TRACE\": return LogLevel.Trace;\r\n case \"DEBUG\": return LogLevel.Trace;\r\n }\r\n return LogLevel.None;\r\n }\r\n\r\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\r\n public static configureLevels(cfg: LoggerLevelsConfig) {\r\n Logger.validateProps(cfg);\r\n if (cfg.defaultLevel !== undefined) {\r\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\r\n }\r\n if (cfg.categoryLevels !== undefined) {\r\n for (const cl of cfg.categoryLevels) {\r\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\r\n }\r\n }\r\n }\r\n\r\n private static isLogLevel(v: string) {\r\n return LogLevel.hasOwnProperty(v);\r\n }\r\n\r\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\r\n public static validateProps(config: any) {\r\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\r\n for (const prop of Object.keys(config)) {\r\n if (!validProps.includes(prop))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\r\n if (prop === \"defaultLevel\") {\r\n if (!Logger.isLogLevel(config.defaultLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\r\n } else if (prop === \"categoryLevels\") {\r\n const value = config[prop];\r\n if (!Array.isArray(value))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\r\n for (const item of config[prop]) {\r\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\r\n if (!Logger.isLogLevel(item.logLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Get the minimum logging level for the specified category. */\r\n public static getLevel(category: string): LogLevel | undefined {\r\n // Prefer the level set for this category specifically\r\n const minLevelForThisCategory = Logger.categoryFilter[category];\r\n if (minLevelForThisCategory !== undefined)\r\n return minLevelForThisCategory;\r\n\r\n // Fall back on the level set for the parent of this category.\r\n const parent = category.lastIndexOf(\".\");\r\n if (parent !== -1)\r\n return Logger.getLevel(category.slice(0, parent));\r\n\r\n // Fall back on the default level.\r\n return Logger.minLevel;\r\n }\r\n\r\n /** Turns off the least severe level at which messages should be displayed by default.\r\n * This turns off logging for all messages for which no category minimum level is defined.\r\n */\r\n public static turnOffLevelDefault(): void {\r\n Logger._minLevel = undefined;\r\n }\r\n\r\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\r\n */\r\n public static turnOffCategories(): void {\r\n Logger._categoryFilter = {};\r\n }\r\n\r\n /** Check if messages in the specified category should be displayed at this level of severity. */\r\n public static isEnabled(category: string, level: LogLevel): boolean {\r\n const minLevel = Logger.getLevel(category);\r\n return (minLevel !== undefined) && (level >= minLevel);\r\n }\r\n\r\n /** Log the specified message to the **error** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\r\n Logger._logError(category, message, metaData);\r\n }\r\n\r\n private static getExceptionMessage(err: unknown): string {\r\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\r\n return BentleyError.getErrorMessage(err) + stack;\r\n }\r\n\r\n /** Log the specified exception. The special \"ExceptionType\" property will be added as metadata.\r\n * @param category The category of the message.\r\n * @param err The exception object.\r\n * @param log The logger output function to use - defaults to Logger.logError\r\n */\r\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\r\n log(category, Logger.getExceptionMessage(err), () => {\r\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err.constructor.name };\r\n });\r\n }\r\n\r\n /** Log the specified message to the **warning** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\r\n Logger._logWarning(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **info** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\r\n Logger._logInfo(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **trace** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\r\n Logger._logTrace(category, message, metaData);\r\n }\r\n}\r\n\r\n/** Simple performance diagnostics utility.\r\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\r\n * the duration in milliseconds.\r\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\r\n *\r\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\r\n * Enable those, if you want to capture timings.\r\n * @public\r\n */\r\nexport class PerfLogger implements IDisposable {\r\n private static _severity: LogLevel = LogLevel.Info;\r\n\r\n private _operation: string;\r\n private _metaData?: LoggingMetaData;\r\n private _startTimeStamp: number;\r\n\r\n public constructor(operation: string, metaData?: LoggingMetaData) {\r\n this._operation = operation;\r\n this._metaData = metaData;\r\n\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\r\n this._startTimeStamp = 0;\r\n return;\r\n }\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\r\n this._startTimeStamp = new Date().getTime(); // take timestamp\r\n }\r\n\r\n private logMessage(): void {\r\n const endTimeStamp: number = new Date().getTime();\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\r\n return;\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\r\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\r\n return {\r\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n });\r\n }\r\n\r\n public dispose(): void {\r\n this.logMessage();\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAC7E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAOvE;;GAEG;AACH,MAAM,CAAN,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA;IACJ,4BAA4B;IAC5B,6CAAO,CAAA;IACP,6BAA6B;IAC7B,yCAAK,CAAA;IACL,+EAA+E;IAC/E,uCAAI,CAAA;AACN,CAAC,EAXW,QAAQ,KAAR,QAAQ,QAWnB;AAkBD;;;GAGG;AACH,MAAM,OAAO,MAAM;IAQjB,8EAA8E;IACvE,MAAM,KAAK,iBAAiB;QACjC,iJAAiJ;QACjJ,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,EAAE,CAAC;YAC5C,MAAM,CAAC,kBAAkB,GAAG,IAAI,OAAO,EAAc,CAAC;QACxD,CAAC;QAED,OAAO,MAAM,CAAC,kBAAkB,CAAC;IACnC,CAAC;IAID;;;OAGG;IACI,MAAM,KAAK,cAAc;QAC9B,kDAAkD;QAClD,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAID;;;OAGG;IACI,MAAM,KAAK,QAAQ;QACxB,qDAAqD;QACrD,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAKD,0FAA0F;IACnF,MAAM,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QAAQ,CAAC,IAAI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Logging\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\r\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\r\nimport { IDisposable } from \"./Disposable\";\r\nimport { staticLoggerMetadata } from \"./internal/staticLoggerMetadata\";\r\n\r\n/** Defines the *signature* for a log function.\r\n * @public\r\n */\r\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\r\n\r\n/** Use to categorize logging messages by severity.\r\n * @public\r\n */\r\nexport enum LogLevel {\r\n /** Tracing and debugging - low level */\r\n Trace,\r\n /** Information - mid level */\r\n Info,\r\n /** Warnings - high level */\r\n Warning,\r\n /** Errors - highest level */\r\n Error,\r\n /** Higher than any real logging level. This is used to turn a category off. */\r\n None,\r\n}\r\n\r\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\r\n * @public\r\n */\r\nexport interface LoggerCategoryAndLevel {\r\n category: string;\r\n logLevel: string;\r\n}\r\n\r\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\r\n * @public\r\n */\r\nexport interface LoggerLevelsConfig {\r\n defaultLevel?: string;\r\n categoryLevels?: LoggerCategoryAndLevel[];\r\n}\r\n\r\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\r\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\r\n * @public\r\n */\r\nexport class Logger {\r\n protected static _logError: LogFunction | undefined;\r\n protected static _logWarning: LogFunction | undefined;\r\n protected static _logInfo: LogFunction | undefined;\r\n protected static _logTrace: LogFunction | undefined;\r\n\r\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\r\n\r\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\r\n public static get onLogLevelChanged(): BeEvent<() => void> {\r\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\r\n if (undefined === Logger._onLogLevelChanged) {\r\n Logger._onLogLevelChanged = new BeEvent<() => void>();\r\n }\r\n\r\n return Logger._onLogLevelChanged;\r\n }\r\n\r\n private static _categoryFilter: {[categoryName: string]: LogLevel | undefined} = {};\r\n\r\n /** Maps category names to the least severe level at which messages in that category should be displayed,\r\n * or `undefined` if a minimum has not been defined.\r\n * @see [[setLevel]] to change the minimum logging level for a category.\r\n */\r\n public static get categoryFilter(): Readonly<{[categoryName: string]: LogLevel | undefined}> {\r\n // NOTE: this property is accessed by native code.\r\n return this._categoryFilter;\r\n }\r\n\r\n private static _minLevel: LogLevel | undefined;\r\n\r\n /** The least severe level at which messages should be displayed by default.\r\n * @see [[setLevelDefault]] to change this default.\r\n * @see [[setLevel]] to override this default for specific categories.\r\n */\r\n public static get minLevel(): LogLevel | undefined {\r\n // NOTE: this property is accessed by native code. */\r\n return this._minLevel;\r\n }\r\n\r\n /** Should the call stack be included when an exception is logged? */\r\n public static logExceptionCallstacks = false;\r\n\r\n /** Initialize the logger streams. Should be called at application initialization time. */\r\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\r\n Logger._logError = logError;\r\n Logger._logWarning = logWarning;\r\n Logger._logInfo = logInfo;\r\n Logger._logTrace = logTrace;\r\n Logger.turnOffLevelDefault();\r\n Logger.turnOffCategories();\r\n }\r\n\r\n /** Initialize the logger to output to the console. */\r\n public static initializeToConsole(): void {\r\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\r\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\r\n\r\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\r\n }\r\n\r\n /** merge the supplied metadata with all static metadata into one object */\r\n public static getMetaData(metaData?: LoggingMetaData): object {\r\n const metaObj = {};\r\n for (const meta of staticLoggerMetadata) {\r\n const val = BentleyError.getMetaData(meta[1]);\r\n if (val)\r\n Object.assign(metaObj, val);\r\n }\r\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\r\n return metaObj;\r\n }\r\n\r\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\r\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\r\n const metaObj = this.getMetaData(metaData);\r\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\r\n }\r\n\r\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\r\n public static setLevelDefault(minLevel: LogLevel): void {\r\n this._minLevel = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\r\n * specified category should be displayed.\r\n */\r\n public static setLevel(category: string, minLevel: LogLevel) {\r\n Logger._categoryFilter[category] = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Interpret a string as the name of a LogLevel */\r\n public static parseLogLevel(str: string): LogLevel {\r\n switch (str.toUpperCase()) {\r\n case \"EXCEPTION\": return LogLevel.Error;\r\n case \"FATAL\": return LogLevel.Error;\r\n case \"ERROR\": return LogLevel.Error;\r\n case \"WARNING\": return LogLevel.Warning;\r\n case \"INFO\": return LogLevel.Info;\r\n case \"TRACE\": return LogLevel.Trace;\r\n case \"DEBUG\": return LogLevel.Trace;\r\n }\r\n return LogLevel.None;\r\n }\r\n\r\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\r\n public static configureLevels(cfg: LoggerLevelsConfig) {\r\n Logger.validateProps(cfg);\r\n if (cfg.defaultLevel !== undefined) {\r\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\r\n }\r\n if (cfg.categoryLevels !== undefined) {\r\n for (const cl of cfg.categoryLevels) {\r\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\r\n }\r\n }\r\n }\r\n\r\n private static isLogLevel(v: string) {\r\n return LogLevel.hasOwnProperty(v);\r\n }\r\n\r\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\r\n public static validateProps(config: any) {\r\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\r\n for (const prop of Object.keys(config)) {\r\n if (!validProps.includes(prop))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\r\n if (prop === \"defaultLevel\") {\r\n if (!Logger.isLogLevel(config.defaultLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\r\n } else if (prop === \"categoryLevels\") {\r\n const value = config[prop];\r\n if (!Array.isArray(value))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\r\n for (const item of config[prop]) {\r\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\r\n if (!Logger.isLogLevel(item.logLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Get the minimum logging level for the specified category. */\r\n public static getLevel(category: string): LogLevel | undefined {\r\n // Prefer the level set for this category specifically\r\n const minLevelForThisCategory = Logger.categoryFilter[category];\r\n if (minLevelForThisCategory !== undefined)\r\n return minLevelForThisCategory;\r\n\r\n // Fall back on the level set for the parent of this category.\r\n const parent = category.lastIndexOf(\".\");\r\n if (parent !== -1)\r\n return Logger.getLevel(category.slice(0, parent));\r\n\r\n // Fall back on the default level.\r\n return Logger.minLevel;\r\n }\r\n\r\n /** Turns off the least severe level at which messages should be displayed by default.\r\n * This turns off logging for all messages for which no category minimum level is defined.\r\n */\r\n public static turnOffLevelDefault(): void {\r\n Logger._minLevel = undefined;\r\n }\r\n\r\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\r\n */\r\n public static turnOffCategories(): void {\r\n Logger._categoryFilter = {};\r\n }\r\n\r\n /** Check if messages in the specified category should be displayed at this level of severity. */\r\n public static isEnabled(category: string, level: LogLevel): boolean {\r\n const minLevel = Logger.getLevel(category);\r\n return (minLevel !== undefined) && (level >= minLevel);\r\n }\r\n\r\n /** Log the specified message to the **error** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\r\n Logger._logError(category, message, metaData);\r\n }\r\n\r\n private static getExceptionMessage(err: unknown): string {\r\n if (err === undefined) {\r\n return \"Error: err is undefined.\";\r\n }\r\n if (err === null) {\r\n return \"Error: err is null.\";\r\n }\r\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\r\n return BentleyError.getErrorMessage(err) + stack;\r\n }\r\n\r\n /** Log the specified exception. The special \"ExceptionType\" property will be added as metadata.\r\n * @param category The category of the message.\r\n * @param err The exception object.\r\n * @param log The logger output function to use - defaults to Logger.logError\r\n */\r\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\r\n log(category, Logger.getExceptionMessage(err), () => {\r\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\"};\r\n });\r\n }\r\n\r\n /** Log the specified message to the **warning** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\r\n Logger._logWarning(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **info** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\r\n Logger._logInfo(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **trace** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\r\n Logger._logTrace(category, message, metaData);\r\n }\r\n}\r\n\r\n/** Simple performance diagnostics utility.\r\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\r\n * the duration in milliseconds.\r\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\r\n *\r\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\r\n * Enable those, if you want to capture timings.\r\n * @public\r\n */\r\nexport class PerfLogger implements IDisposable {\r\n private static _severity: LogLevel = LogLevel.Info;\r\n\r\n private _operation: string;\r\n private _metaData?: LoggingMetaData;\r\n private _startTimeStamp: number;\r\n\r\n public constructor(operation: string, metaData?: LoggingMetaData) {\r\n this._operation = operation;\r\n this._metaData = metaData;\r\n\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\r\n this._startTimeStamp = 0;\r\n return;\r\n }\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\r\n this._startTimeStamp = new Date().getTime(); // take timestamp\r\n }\r\n\r\n private logMessage(): void {\r\n const endTimeStamp: number = new Date().getTime();\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\r\n return;\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\r\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\r\n return {\r\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n });\r\n }\r\n\r\n public dispose(): void {\r\n this.logMessage();\r\n }\r\n}\r\n\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-bentley",
|
|
3
|
-
"version": "4.9.0
|
|
3
|
+
"version": "4.9.0",
|
|
4
4
|
"description": "Bentley JavaScript core components",
|
|
5
5
|
"main": "lib/cjs/core-bentley.js",
|
|
6
6
|
"module": "lib/esm/core-bentley.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"nyc": "^15.1.0",
|
|
36
36
|
"rimraf": "^3.0.2",
|
|
37
37
|
"typescript": "~5.3.3",
|
|
38
|
-
"@itwin/build-tools": "4.9.0
|
|
38
|
+
"@itwin/build-tools": "4.9.0"
|
|
39
39
|
},
|
|
40
40
|
"nyc": {
|
|
41
41
|
"extends": "./node_modules/@itwin/build-tools/.nycrc"
|