Skip to content

Commit

Permalink
docs: readme using official logger
Browse files Browse the repository at this point in the history
  • Loading branch information
sukovanej committed Dec 2, 2024
1 parent 36e9015 commit e6a7535
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,25 @@

Logging batteris for effect-ts.

## Consider using the official `effect/Logger` instead

Most of the functionality provided by this library is already present directly in the `effect`
package. In case of the pretty logger, you should strongly consider using the
[Logger.pretty](https://effect-ts.github.io/effect/effect/Logger.ts.html#pretty) instead. And,
in case of the JSON logger, consider using the
[Logger.json](https://effect-ts.github.io/effect/effect/Logger.ts.html#json). Just be aware
of few differences:

- the `Logger.json` includes the log annotations in the `annotations` field, the `JsonLogger.layer()`
spreads the annotations into the root of the output JSON
- the `Logger.json` outputs the message as an array into the `message` field, the `JsonLogger.layer()`
concatenates the message into a single string

These decisions about the output JSON format were motivated by the fact that I'm targetting
the Datadog platform. If you want the same output format, you can still achieve it by using
the [Logger.structuredLogger](https://effect-ts.github.io/effect/effect/Logger.ts.html#structuredlogger)
and modifying the output using [Logger.map](https://effect-ts.github.io/effect/effect/Logger.ts.html#map).

## [Pretty logger](examples/pretty-logger.ts)

Use `PrettyLogger.make` to create the pretty logger or `PrettyLogger.layer` to
Expand Down

0 comments on commit e6a7535

Please sign in to comment.