Unverified Commit 471818f4 authored by Hong Minhee's avatar Hong Minhee
Browse files

How to set up loggers (tutorial)

[ci skip]
parent 4662633d
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -42,10 +42,7 @@ bun add @logtape/logtape

:::

[JSR]: https://jsr.io/@logtape/logtape
[npm]: https://www.npmjs.com/package/@logtape/logtape

Then, you can `configure()` the logger in the entry point of your app:
Then, you can [`configure()`] the logger in the entry point of your app:

~~~~ typescript
import { configure, getConsoleSink } from "@logtape/logtape";
@@ -92,6 +89,10 @@ The `configure()` function takes an object with three properties:
    level can be one of the following: `"debug"`, `"info"`, `"warning"`,
    `"error"`, or `"fatal"`.

[JSR]: https://jsr.io/@logtape/logtape
[npm]: https://www.npmjs.com/package/@logtape/logtape
[`configure()`]: https://jsr.io/@logtape/logtape/doc/~/configure


Categories
----------
+38 −0
Original line number Diff line number Diff line
@@ -271,7 +271,45 @@ need to share any context data here.
The `Federation` object is now ready to handle incoming requests.  Let's move on
to the next step.

> [!TIP]
> Although it's not mandatory, we highly recommend to set up loggers to see
> what's going on in the server.  To set up loggers, you need to install
> [LogTape] first:
>
> ::: code-group
>
> ~~~~ sh [Deno]
> deno add @logtape/logtape
> ~~~~
>
> ~~~~ sh [Node.js]
> npm add @logtape/logtape
> ~~~~
>
> ~~~~ sh [Bun]
> bun add @logtape/logtape
> ~~~~
>
> :::
>
> Then, you can set up loggers by calling [`configure()`] function at the
> top of the *server.ts* file:
>
> ~~~~ typescript
> import { configure, getConsoleSink } from "@logtape/logtape";
>
> await configure({
>   sinks: { console: getConsoleSink() },
>   filters: {},
>   loggers: [
>     { category: "fedify",  sinks: ["console"], level: "info" },
>   ],
> });
> ~~~~

[`Deno.openKv()`]: https://deno.land/api?s=Deno.openKv
[LogTape]: https://github.com/dahlia/logtape
[`configure()`]: https://jsr.io/@logtape/logtape/doc/~/configure


Actor dispatcher