@aglyn/shared-util-logger 1.0.0-beta.143 → 1.0.0-beta.145

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.
Files changed (2) hide show
  1. package/README.md +19 -19
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,34 +1,34 @@
1
1
  # @aglyn/shared-util-logger
2
2
 
3
- ---
3
+ A small leveled logger: named instances, a log level per instance, and a
4
+ replaceable handler. The larger Aglyn packages log through it, and it works on
5
+ its own. Its shape follows `@firebase/logger`; it depends on nothing.
4
6
 
5
- # Logger Helper
7
+ > Beta. Published from the Aglyn monorepo under the `beta` dist-tag; APIs can change between beta releases.
6
8
 
7
- This library was generated with [Nx](https://nx.dev).
9
+ ## Install
8
10
 
9
- Logger framework and logical flow is inspired by `@firebase/logger`
11
+ npm install @aglyn/shared-util-logger@beta
10
12
 
11
- This package serves as the base of all logging in the JS SDK. Any logging that is intended to be
12
- visible to Firebase end developers should go through this module.
13
+ ## Usage
13
14
 
14
- ## Basic Usage
15
-
16
- Firebase components should import the `Logger` class and instantiate a new instance by passing a
17
- component name (
18
- e.g. `@aglyn/<project-name>`) to the constructor.
19
-
20
- _e.g._
15
+ Create one `Logger` per component, named for it:
21
16
 
22
17
  ```typescript
23
- import { Logger } from '@aglyn/shared-util-logger'
18
+ import { Logger, LogLevel } from '@aglyn/shared-util-logger'
24
19
 
25
- const logger = new Logger(`@aglyn/<project-name>`)
20
+ const logger = new Logger('@acme/checkout')
21
+ logger.setLogLevel(LogLevel.WARN)
22
+ logger.warn('inventory is stale', { sku })
26
23
  ```
27
24
 
25
+ `logLevel` decides which calls reach the handler. `logHandler` replaces the
26
+ default handler, which writes to the console, and `userLogHandler` adds one
27
+ that runs beside it, for forwarding logs somewhere else.
28
+
28
29
  Each `Logger` instance supports 5 log functions each to be used in a specific instance:
29
30
 
30
- - `debug`: Internal logs; use this to allow developers to send us their debug logs for us to be able
31
- to diagnose an issue.
31
+ - `debug`: Internal detail, for diagnosing an issue.
32
32
  - `log`: Use to inform your user about things they may need to know.
33
33
  - `info`: Use if you have to inform the user about something that they need to take a concrete
34
34
  action on. Once they take that action, the log should go away.
@@ -43,6 +43,6 @@ Each log will be formatted in the following manner:
43
43
  `"[${new Date()}] ${COMPONENT_NAME}: ${...args}"`
44
44
  ```
45
45
 
46
- ## Running unit tests
46
+ ## License
47
47
 
48
- Run `nx test shared-util-logger` to execute the unit tests via [Jest](https://jestjs.io).
48
+ Apache-2.0. Source: https://github.com/aglyn/aglyn/tree/main/libs/shared/util/logger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aglyn/shared-util-logger",
3
- "version": "1.0.0-beta.143",
3
+ "version": "1.0.0-beta.145",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {