pass root logger, don't init new ones

This commit is contained in:
JT2M0L3Y
2026-10-21 19:31:02 -07:00
parent 217291e531
commit 288c0eb08f
16 changed files with 56 additions and 62 deletions
+6 -3
View File
@@ -31,12 +31,15 @@ entry. Set `LOG_LEVEL` to configure the minimum level (defaults to `info`).
```ts
import { createLogger } from './components/index.js'
const logger = createLogger({ component: 'client' })
logger.info({ username }, 'Client started')
const logger = createLogger({ component: 'request', requestId })
logger.info('Request started')
```
Log entries are JSON and include the structured fields provided to the log
method, along with `component` and (outside production) `caller`.
method, along with `component` and (outside production) `caller`. The root Pino
instance is shared; create one child when entering a context, then pass that
same child logger through the context's work. Create another child only when
you need to add more scoped bindings; child creation does not mutate its parent.
## Environment Setup
* Clone this repo using `git clone https://github.com/kevinthedang/discord-ollama.git` or just use [GitHub Desktop](https://desktop.github.com/) to clone the repo.