Error logs
OpenBot writes a log line at level Error when something fails on the server.
OpenBot does not send these logs to other services. You can add this yourself with an Effect logger.
What OpenBot logs
| Source | When |
|---|---|
http |
A request ends with a status of 500 or higher. |
turn |
A Turn ends with the status Failed. |
startup |
OpenBot fails to start, for example because of bad configuration. |
Normal request errors, such as 400, 401, 404, or 409, are not logged as errors. Work that a person interrupts on purpose is not logged either.
Each error log has the message OpenBot operation failed and these annotations. An annotation is a named value that is attached to a log line.
| Annotation | Meaning |
|---|---|
source, operation |
Which part of OpenBot failed. |
errorType |
A short name for the error, when OpenBot knows one. |
requestId, method, route, status |
For HTTP failures. route is the route pattern, not the real path. |
sessionId, turnId |
For Turn failures. |
The log also has the cause of the failure. The cause can hold error messages and other private data.
Send errors to your own service
When you run OpenBot from your own code, add a logger with Logger.layer. Use mergeWithExisting: true to keep the other loggers.
Provide it outside the server, so that it stays open until the server has closed.
import { NodeRuntime } from "@effect/platform-node"import { EnvironmentConfiguration, Server } from "@openbot-build/openbot"import { Effect, Layer, Logger, References } from "effect"import { FetchHttpClient } from "effect/http"
const alerts = Logger.layer( [ Logger.make((log) => { if (log.logLevel !== "Error" && log.logLevel !== "Fatal") return const annotations = log.fiber.getRef(References.CurrentLogAnnotations) // Send only the values that you need, for example to a chat bot. console.log("alert", annotations["source"], annotations["operation"]) }), ], { mergeWithExisting: true },)
NodeRuntime.runMain( Effect.gen(function* () { const settings = yield* EnvironmentConfiguration.load return yield* Layer.launch( Server.layer(settings).pipe(Layer.provide(FetchHttpClient.layer)), ) }).pipe(Effect.provide(alerts)),)A logger must not block. To call a slow service, put each event in a queue and send it from a background fiber. A fiber is a light thread that Effect runs.