@genesislcap/foundation-logger 14.203.0 → 14.203.2

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/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![lerna](https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg)](https://lerna.js.org/)
4
4
  [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](https://www.typescriptlang.org/)
5
5
 
6
- `foundation-logger` provides a logging utility that currently wraps [consola](https://github.com/unjs/consola).
6
+ `foundation-logger` provides a logging utility that currently wraps version 2 of [consola](https://github.com/unjs/consola).
7
7
 
8
8
  ## Installation
9
9
 
@@ -23,6 +23,39 @@ To enable this module in your application, follow the steps below.
23
23
  }
24
24
  ```
25
25
 
26
+ 2. Create a logger in my-package/utils/logger.ts for example.
27
+
28
+ ```ts
29
+ import { createLogger } from '@genesislcap/foundation-logger';
30
+ export const logger = createLogger('my-package');
31
+ ```
32
+
33
+ The logger will be set to `LogLevel.Debug` by default, however you can pass options as the second parameter to tailor this.
34
+
35
+ ```ts
36
+ export const logger = createLogger('my-package', { level: LogLevel.Debug, ... });
37
+ ```
38
+
39
+ `LoggerOptions` type extends the `ConsolaOptions` type.
40
+
41
+ 3. Use the logger in your package.
42
+
43
+ ```ts
44
+ import { logger } from '../utils';
45
+ ...
46
+ logger.debug('Checks complete');
47
+ ```
48
+
49
+ 4. Explicitly set the log level of an imported foundation package when needed.
50
+
51
+ ```ts
52
+ import { logger as commsLogger } from '@genesislcap/foundation-comms';
53
+ import { logger as storeLogger } from '@genesislcap/foundation-store';
54
+ import { LogLevel } from '@genesislcap/foundation-logger';
55
+ commsLogger.level = LogLevel.Warn;
56
+ storeLogger.level = LogLevel.Silent;
57
+ ```
58
+
26
59
  ## [API Docs](./docs/api/index.md)
27
60
 
28
61
  ## License
@@ -30,4 +63,4 @@ To enable this module in your application, follow the steps below.
30
63
  Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact [Genesis Global](https://genesis.global/contact-us/) for more details.
31
64
 
32
65
  ### Licensed components
33
- Genesis low-code platform
66
+ Genesis low-code platform
@@ -77,6 +77,13 @@ export declare const defaultLoggerOptions: LoggerOptions;
77
77
  * logger.warn('Not available in this browser.');
78
78
  * ```
79
79
  *
80
+ * @example Explicitly set the level of an imported package.
81
+ * ```ts
82
+ * import { logger as commsLogger } from '@genesislcap/foundation-comms';
83
+ * import { LogLevel } from '@genesislcap/foundation-logger';
84
+ * commsLogger.level = LogLevel.Warn;
85
+ * ```
86
+ *
80
87
  * @param name - The name to give the logger.
81
88
  * @param options - The options to use when creating the logger.
82
89
  * @returns The resulting logger.
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAY,MAAM,SAAS,CAAC;AAG5D;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,cAAc;CAAG;AAExD;;;;;;;GAOG;AACH,MAAM,WAAW,MAAO,SAAQ,OAAO;IACrC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvF;AAED;;;GAGG;AACH,MAAM,WAAW,MAAO,SAAQ,OAAO;CAAG;AAE1C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAElC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAoC,GAAG,MAAM,CAgBhG"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAY,MAAM,SAAS,CAAC;AAG5D;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,aAAc,SAAQ,cAAc;CAAG;AAExD;;;;;;;GAOG;AACH,MAAM,WAAW,MAAO,SAAQ,OAAO;IACrC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvF;AAED;;;GAGG;AACH,MAAM,WAAW,MAAO,SAAQ,OAAO;CAAG;AAE1C;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,aAElC,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,aAAoC,GAAG,MAAM,CAmBhG"}
@@ -37,15 +37,22 @@ export const defaultLoggerOptions = {
37
37
  * logger.warn('Not available in this browser.');
38
38
  * ```
39
39
  *
40
+ * @example Explicitly set the level of an imported package.
41
+ * ```ts
42
+ * import { logger as commsLogger } from '@genesislcap/foundation-comms';
43
+ * import { LogLevel } from '@genesislcap/foundation-logger';
44
+ * commsLogger.level = LogLevel.Warn;
45
+ * ```
46
+ *
40
47
  * @param name - The name to give the logger.
41
48
  * @param options - The options to use when creating the logger.
42
49
  * @returns The resulting logger.
43
50
  * @public
44
51
  */
45
52
  export function createLogger(name, options = defaultLoggerOptions) {
46
- const baseLogger = consola.create(options);
47
- const logger = baseLogger.withTag(name);
48
- return Object.assign(Object.assign({}, logger), { deprecated: (symbol, instruction = 'Consult docs for better alternative.', removalVersionTarget) => {
49
- logger.warn(`Deprecated symbol used '${symbol}'. ${instruction}`, `${removalVersionTarget ? `Will be removed in version ${removalVersionTarget}.` : ''}`);
50
- } });
53
+ const logger = consola.create(Object.assign(Object.assign({}, options), { defaults: Object.assign(Object.assign({}, (options.defaults || {})), { tag: name }) }));
54
+ logger.deprecated = (symbol, instruction = 'Consult docs for better alternative.', removalVersionTarget) => {
55
+ logger.warn(`Deprecated symbol used '${symbol}'. ${instruction}`, `${removalVersionTarget ? `Will be removed in version ${removalVersionTarget}.` : ''}`);
56
+ };
57
+ return logger;
51
58
  }
@@ -175,7 +175,7 @@
175
175
  {
176
176
  "kind": "Function",
177
177
  "canonicalReference": "@genesislcap/foundation-logger!createLogger:function(1)",
178
- "docComment": "/**\n * Creates a logger with the given name and options.\n *\n * @param name - The name to give the logger.\n *\n * @param options - The options to use when creating the logger.\n *\n * @returns The resulting logger.\n *\n * @example\n *\n * Create a logger in my-package/utils.\n * ```ts\n * import { createLogger } from '@genesislcap/foundation-logger';\n * export const logger = createLogger('my-package');\n * ```\n *\n * @example\n *\n * Using the logger within my-package.\n * ```ts\n * import { logger } from '../utils';\n * logger.debug(`Data retrieved from ${resourceName}`);\n * logger.info(this.toggled ? 'On' : 'Off');\n * logger.warn('Not available in this browser.');\n * ```\n *\n * @public\n */\n",
178
+ "docComment": "/**\n * Creates a logger with the given name and options.\n *\n * @param name - The name to give the logger.\n *\n * @param options - The options to use when creating the logger.\n *\n * @returns The resulting logger.\n *\n * @example\n *\n * Create a logger in my-package/utils.\n * ```ts\n * import { createLogger } from '@genesislcap/foundation-logger';\n * export const logger = createLogger('my-package');\n * ```\n *\n * @example\n *\n * Using the logger within my-package.\n * ```ts\n * import { logger } from '../utils';\n * logger.debug(`Data retrieved from ${resourceName}`);\n * logger.info(this.toggled ? 'On' : 'Off');\n * logger.warn('Not available in this browser.');\n * ```\n *\n * @example\n *\n * Explicitly set the level of an imported package.\n * ```ts\n * import { logger as commsLogger } from '@genesislcap/foundation-comms';\n * import { LogLevel } from '@genesislcap/foundation-logger';\n * commsLogger.level = LogLevel.Warn;\n * ```\n *\n * @public\n */\n",
179
179
  "excerptTokens": [
180
180
  {
181
181
  "kind": "Content",
@@ -20,6 +20,13 @@ import { logType } from 'consola';
20
20
  * logger.warn('Not available in this browser.');
21
21
  * ```
22
22
  *
23
+ * @example Explicitly set the level of an imported package.
24
+ * ```ts
25
+ * import { logger as commsLogger } from '@genesislcap/foundation-comms';
26
+ * import { LogLevel } from '@genesislcap/foundation-logger';
27
+ * commsLogger.level = LogLevel.Warn;
28
+ * ```
29
+ *
23
30
  * @param name - The name to give the logger.
24
31
  * @param options - The options to use when creating the logger.
25
32
  * @returns The resulting logger.
@@ -45,3 +45,13 @@ logger.info(this.toggled ? 'On' : 'Off');
45
45
  logger.warn('Not available in this browser.');
46
46
  ```
47
47
 
48
+ ## Example 3
49
+
50
+ Explicitly set the level of an imported package.
51
+
52
+ ```ts
53
+ import { logger as commsLogger } from '@genesislcap/foundation-comms';
54
+ import { LogLevel } from '@genesislcap/foundation-logger';
55
+ commsLogger.level = LogLevel.Warn;
56
+ ```
57
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-logger",
3
3
  "description": "Genesis Foundation Logger",
4
- "version": "14.203.0",
4
+ "version": "14.203.2",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "3f779b9e65169135dc8fea0605f21d0d65ce263b"
42
+ "gitHead": "8a31c5b68f7b0eecff3e23762c63c3d869ae25bb"
43
43
  }