Skip to content

Commit

Permalink
feat(mojaloop/#2928): add contextual logging functionality (#39)
Browse files Browse the repository at this point in the history
* feat: add contextual logging functionality

* chore: update

* chore: update readme

* chore: documentation

* chore: update readme

* chore: update readme

* chore: test

* chore: lint

* chore: lint

* chore(snapshot): 11.1.0-snapshot.0
  • Loading branch information
kleyow authored Nov 17, 2022
1 parent e7d7f57 commit 8d29f41
Show file tree
Hide file tree
Showing 5 changed files with 2,436 additions and 2,548 deletions.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Edit the file in `./config/default.json` to configure the logger, or set the fol
| --- | --- | --- | --- |
| `LOG_LEVEL` | Also `CSL_LOG_LEVEL` | `info` | `error`, `warn`, `audit`, `trace`, `info`, `perf`, `verbose`, `debug`, `silly` |
| `CSL_LOG_LEVEL` | Sets the log level | `info` | `error`, `warn`, `audit`, `trace`, `info`, `perf`, `verbose`, `debug`, `silly` |
| `LOG_FILTER` | Also `CSL_LOG_FILTER` | `""` | e.g. `"error, trace, verbose" |
| `LOG_FILTER` | Also `CSL_LOG_FILTER` | `""` | e.g. `"error, trace, verbose" |
| `CSL_LOG_FILTER` | Applies a log filter. Specify a comma separated list of individual log levels to be included instead of specifying a `LOG_LEVEL` | `""` | e.g. `"error, trace, verbose" |
| `CSL_LOG_TRANSPORT` | Selects the transport method. Either `console` or `file`. Uses the same transport for errors and standard logs | `console` | `console`, `file`
| `CSL_TRANSPORT_FILE_OPTIONS` | _Optional._ Required if `LOG_TRANSPORT=file`. Configures the winston file transport | See `default.json` | See the [Winston Docs](https://github.com/winstonjs/winston#common-transport-options) |
Expand Down Expand Up @@ -70,6 +70,17 @@ npm run audit:check

And commit the changed `audit-resolve.json` to ensure that CircleCI will build correctly.

## Contextual Logging

If you need contextual logging, an context object can be passed using Logger.child({'context': {a:1}}).info("Message").

```bash
Output: timestamp - info: {
a: 1,
message: 'Message'
}
```

## Automated Releases

As part of our CI/CD process, we use a combination of CircleCI, standard-version
Expand Down
Loading

0 comments on commit 8d29f41

Please sign in to comment.