diff --git a/docs/bun.lockb b/docs/bun.lockb index 3a123ce..e220c58 100755 Binary files a/docs/bun.lockb and b/docs/bun.lockb differ diff --git a/docs/manual/install.md b/docs/manual/install.md index e24fd2d..9b14f00 100644 --- a/docs/manual/install.md +++ b/docs/manual/install.md @@ -7,7 +7,7 @@ JavaScript runtimes and package managers: :::code-group ~~~~ sh [Deno] -deno add @logtape/logtape +deno add jsr:@logtape/logtape ~~~~ ~~~~ sh [npm] @@ -61,8 +61,8 @@ bun add @logtape/logtape@dev > to specify the specific version number of the unstable release: > > ~~~~ sh -> deno add @logtape/logtape@1.2.3-dev.4 # Replace 1.2.3-dev.4 with the actual version number +> deno add jsr:@logtape/logtape@1.2.3-dev.4 # Replace 1.2.3-dev.4 with the actual version number > ~~~~ [JSR]: https://jsr.io/@logtape/logtape -[npm]: https://www.npmjs.com/package/@logtape/logtape \ No newline at end of file +[npm]: https://www.npmjs.com/package/@logtape/logtape diff --git a/docs/manual/sinks.md b/docs/manual/sinks.md index f09e30d..77dc400 100644 --- a/docs/manual/sinks.md +++ b/docs/manual/sinks.md @@ -254,7 +254,7 @@ sink to send log messages to the collector using [@logtape/otel] package: ::: code-group ~~~~ sh [Deno] -deno add @logtape/otel +deno add jsr:@logtape/otel ~~~~ ~~~~ sh [npm] @@ -304,6 +304,89 @@ For more details, see the documentation of [@logtape/otel]. [`getOpenTelemetrySink()`]: https://jsr.io/@logtape/otel/doc/~/getOpenTelemetrySink +Sentry sink +----------- + +If you are using [Sentry] for error monitoring, you can use the Sentry sink to +send log messages to Sentry using [@logtape/sentry] package: + +::: code-group + +~~~~ sh [Deno] +deno add jsr:@logtape/sentry +~~~~ + +~~~~ sh [npm] +npm add @logtape/sentry +~~~~ + +~~~~ sh [pnpm] +pnpm add @logtape/sentry +~~~~ + +~~~~ sh [Yarn] +yarn add @logtape/sentry +~~~~ + +~~~~ sh [Bun] +bun add @logtape/sentry +~~~~ + +::: + +The quickest way to get started is to use the [`getSentrySink()`] function +without any arguments: + +~~~~ typescript twoslash +import { configure } from "@logtape/logtape"; +import { getSentrySink } from "@logtape/sentry"; + +await configure({ + sinks: { + sentry: getSentrySink(), + }, + filters: {}, + loggers: [ + { category: [], sinks: ["sentry"], level: "debug" }, + ], +}); +~~~~ + +The log records will show up in the breadcrumbs of the Sentry issues: + +![LogTape records show up in the breadcrumbs of a Sentry issue.](https://raw.githubusercontent.com/dahlia/logtape-sentry/refs/heads/main/screenshot.png) + +If you want to explicitly configure the Sentry client, you can pass +the [`Client`] instance to the [`getSentrySink()`] function: + +~~~~ typescript twoslash +import { configure } from "@logtape/logtape"; +import { getSentrySink } from "@logtape/sentry"; +import { init } from "@sentry/node"; + +const client = init({ + dsn: process.env.SENTRY_DSN, +}); + +await configure({ + sinks: { + sentry: getSentrySink(client), + }, + filters: {}, + loggers: [ + { category: [], sinks: ["sentry"], level: "debug" }, + ], +}); +~~~~ + +For more details, see the documentation of [@logtape/sentry]. + +[Sentry]: https://sentry.io/ +[@logtape/sentry]: https://github.com/dahlia/logtape-sentry +[`getSentrySink()`]: https://jsr.io/@logtape/sentry/doc/~/getSentrySink +[`Client`]: https://getsentry.github.io/sentry-javascript/interfaces/_sentry_types.Client.html + + Disposable sink --------------- diff --git a/docs/package.json b/docs/package.json index e1215dd..c01baaa 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,5 +1,8 @@ { - "dependencies": {}, + "dependencies": { + "@logtape/sentry": "^0.1.0", + "@sentry/node": "^8.40.0" + }, "devDependencies": { "@biomejs/biome": "^1.8.3", "@cloudflare/workers-types": "^4.20240909.0",