@travetto/log 3.0.2-rc.1 → 3.0.3
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 +4 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<!-- This file was generated by @travetto/doc and should not be modified directly -->
|
|
2
|
-
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/log/DOC.
|
|
2
|
+
<!-- Please modify https://github.com/travetto/travetto/tree/main/module/log/DOC.tsx and execute "npx trv doc" to rebuild -->
|
|
3
3
|
# Logging
|
|
4
|
+
|
|
4
5
|
## Logging framework that integrates at the console.log level.
|
|
5
6
|
|
|
6
7
|
**Install: @travetto/log**
|
|
@@ -61,8 +62,6 @@ export type ConsoleEvent = {
|
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
The [LogEvent](https://github.com/travetto/travetto/tree/main/module/log/src/types.ts#L5) is an extension of the [ConsoleEvent](https://github.com/travetto/travetto/tree/main/module/base/src/types.ts#L12) with the addition of two fields:
|
|
64
|
-
|
|
65
|
-
|
|
66
65
|
* `message` - This is the primary argument passed to the console statement, if it happens to be a string, otherwise the field is left empty
|
|
67
66
|
* `context` - This is the final argument passed to the console statement, if it happens to be a simple object. This is useful for external loggers that allow for searching/querying by complex data
|
|
68
67
|
|
|
@@ -85,9 +84,9 @@ export class CustomLogger implements Logger {
|
|
|
85
84
|
```
|
|
86
85
|
|
|
87
86
|
## Logging to External Systems
|
|
88
|
-
By default the logging functionality logs messages directly to the console, relying on the `util.inspect` method, as is the standard behavior. When building distributed systems, with multiple separate logs, it is useful to rely on structured logging for common consumption. The framework supports logging as [JSON](https://www.json.org), which is easily consumable by services like [elasticsearch](https://elastic.co) or [AWS Cloudwatch](https://aws.amazon.com/cloudwatch/) if running as a lambda or in a docker container.
|
|
87
|
+
By default the logging functionality logs messages directly to the console, relying on the `util.inspect` method, as is the standard behavior. When building distributed systems, with multiple separate logs, it is useful to rely on structured logging for common consumption. The framework supports logging as [JSON](https://www.json.org), which is easily consumable by services like [elasticsearch](https://elastic.co) or [AWS Cloudwatch](https://aws.amazon.com/cloudwatch/) if running as a lambda or in a docker container.
|
|
89
88
|
|
|
90
|
-
The main caveat that comes with this, is that not all objects can be converted to JSON (specifically circular dependencies, and unsupported types). That end, the framework recommends logging with the following format, `message: string`
|
|
89
|
+
The main caveat that comes with this, is that not all objects can be converted to JSON (specifically circular dependencies, and unsupported types). That end, the framework recommends logging with the following format, `message: string` `context: Record<string, Primitive>`. Here context can be recursive, but the general idea is to only pass in known data structures that will not break the [JSON](https://www.json.org) production.
|
|
91
90
|
|
|
92
91
|
## Environment Configuration
|
|
93
92
|
|
|
@@ -123,7 +122,6 @@ export class CommonLoggerConfig {
|
|
|
123
122
|
```
|
|
124
123
|
|
|
125
124
|
The following environment variables have control over the default logging config:
|
|
126
|
-
|
|
127
125
|
* `TRV_LOG_FORMAT` - This determines whether or not the output is standard text lines, or is it output as a single line of [JSON](https://www.json.org)
|
|
128
126
|
* `TRV_LOG_FILE` - This determines whether or not the logging goes to the console or if it is written to a file
|
|
129
127
|
* `TRV_LOG_PLAIN` - Allows for an override of whether or not to log colored output, this defaults to values provided by the [Terminal](https://github.com/travetto/travetto/tree/main/module/terminal#readme "General terminal support") in response to `FORCE_COLOR` and `NO_COLOR`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/log",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Logging framework that integrates at the console.log level.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"directory": "module/log"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/config": "^3.0.
|
|
27
|
-
"@travetto/di": "^3.0.
|
|
28
|
-
"@travetto/terminal": "^3.0.
|
|
26
|
+
"@travetto/config": "^3.0.3",
|
|
27
|
+
"@travetto/di": "^3.0.3",
|
|
28
|
+
"@travetto/terminal": "^3.0.3"
|
|
29
29
|
},
|
|
30
30
|
"travetto": {
|
|
31
31
|
"displayName": "Logging"
|