Files
logger/README.md
T
mifi f13fd6d96b
ci/woodpecker/push/ci Pipeline failed
Initial commit
2026-08-05 01:09:30 -03:00

38 lines
1.6 KiB
Markdown

# @mifi/logger
Intentional, namespaced logging for TypeScript browser and Node.js applications.
```ts
import { createLogger } from "@mifi/logger";
const logger = createLogger({ environment: "production" });
logger.child("WIDGET").debug("Rendered", () => ({ expensive: "only evaluated when shown" }));
```
## Runtime policy
Development shows every level, staging shows `warn` and `error`, and production shows `error` only. Browser sessions can override the policy with `sessionStorage.showLoggingFor`:
```text
debug
debug:WIDGET,API
```
Containers can use `MIFI_LOG_LEVEL` and `MIFI_LOG_NAMESPACES`. Explicit `level` options take precedence.
## Sentry
The Sentry adapter has no SDK dependency. Provide the SDK that your application already uses. In a production browser, errors go to Sentry without also appearing in the console. In Node, they go to both Sentry and stderr.
```ts
import * as Sentry from "@sentry/nextjs";
import { createLogger } from "@mifi/logger";
import { createSentrySink } from "@mifi/logger/sentry";
const logger = createLogger({ environment: "production", sentry: createSentrySink(Sentry) });
```
## Publishing
Woodpecker verifies pull requests, `main`, and version tags, and reports CI to Mattermost. To publish, push a tag matching the package version (for example, `v0.9.1`). The tag build verifies the package before publishing it to the private `@mifi` registry and reports the result to Mattermost. It uses the existing global `gitea_package_token`, `mattermost_bot_access_token`, `mattermost_tests_channel_id`, `mattermost_pushes_channel_id`, and `mattermost_post_api_url` secrets.