Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
馃摑 Update docs, changelog and meta
Browse files Browse the repository at this point in the history
Related: #28
  • Loading branch information
smolijar committed Nov 22, 2019
1 parent 0f7f3a7 commit 76d7e5f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

### Added
- parent logger name inheritance
- logging to sentry

### Changed
- `pino.pretty` replaced with `util.inspect`
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,30 @@ All loglevels up to warning (exclusive) - trace, debug and info - are logged to

All loglevels from warning up (inclusive) - warning, error, fatal - are logged to `stderr` **only**.

## Using Sentry

Cosmas logs every message to [Sentry](https://sentry.io/) for you, when configured. This feature is disabled by default.

Sentry SDK `@sentry/node` is a peer dependency. If you want cosmas to use it, install it in your project.

```js
// (1) Let cosmas initialize sentry with provided DSN
const myLogger = logger({ sentry: 'https://<key>@sentry.io/<project>' })

// (2) Configure sentry yourself and let cosmas use it
Sentry.init({/*...*/})
const myLogger = logger({ sentry: true })

// (3) Disable sentry (default, no need to send false option)
const myLogger = logger({ sentry: false })
```

When configured, cosmas (additionally to standard logging) captures all logs via Sentry SDK. Logs containing `stack` are logged as exceptions via `captureException` (preserves stack trace) and all other messages via `captureMessage`.

Either way, scope is appropriately set, as well as all payload is passed on in scope's metadata.



## Express middleware

`cosmas` contains an express middleware which you can use to log all requests and responses of your express application.
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
]
},
"author": "Michal Vlas谩k <michal.vlasak@ackee.cz>",
"contributors": [
"Michal Vlas谩k <michal.vlasak@ackee.cz>",
"Jaroslav 艩mol铆k <grissius@gmail.com>"
],
"license": "ISC",
"engines": {
"node": ">=6"
Expand Down

0 comments on commit 76d7e5f

Please sign in to comment.