[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79GKJH0B1TCAN7CMCWN3GCR":3,"skill-same:01M79GKJH0B1TCAN7CMCWN3GCR":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M79GKJH0B1TCAN7CMCWN3GCR","saasaloy-logger",null,"Runbook for the logger capability — structured, level-controlled, request-correlated logging from packages\u002Flogger with per-provider modules (logger-console). Use when logging from a route or a worker, reading logs with wrangler tail or Workers Logs, setting LOG_LEVEL or LOGGER_PROVIDER, correlating lines by request id, understanding what redaction catches, or writing a custom log provider.","mimukit\u002Fsaasaloy","mimukit","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F11677026?v=4","01M79GFSERAQQ77QPQMC1N0Y6M","Mukitul Islam Mukit","01M79GFSFA4WMGEEBHA68N59WV",4,"MIT","https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fmodules\u002Flogger\u002Fskills\u002Fsaasaloy-logger\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: saasaloy-logger\ndescription: Runbook for the logger capability — structured, level-controlled, request-correlated logging from packages\u002Flogger with per-provider modules (logger-console). Use when logging from a route or a worker, reading logs with wrangler tail or Workers Logs, setting LOG_LEVEL or LOGGER_PROVIDER, correlating lines by request id, understanding what redaction catches, or writing a custom log provider.\n---\n\n# logger — structured logging from `packages\u002Flogger`\n\n`packages\u002Flogger` (`@repo\u002Flogger`) is the capability core: six levels, a level threshold, child\nloggers for correlation, error serialization, key-based redaction, and a **provider registry**. It\nhas **zero runtime dependencies**. Each provider ships as its own module — today just\n`logger-console` — dropping one file into `src\u002Fproviders\u002F` and registering itself in the array in\n`src\u002Findex.ts`.\n\n> **`logger-console` is the production default, not a dev stand-in.** It shares a naming pattern\n> with `email-console` and means the opposite. On Cloudflare Workers `console.*` *is* the log\n> pipeline: Workers Logs ingests it and `wrangler tail` streams it. `email-console` logs a message\n> instead of sending it and must never be deployed; `logger-console` writes structured objects to\n> the platform's own sink and is what you ship.\n\nCallers import `@repo\u002Flogger`, or read `c.get(\"log\")` in a route, and never learn which provider is\nactive.\n\n## Log from a route\n\n`api`'s spine already mounts the correlation middleware, so a route just reads the logger off the\ncontext. Compose `LoggerVariables` into the sub-app's generic to type it — a route can't import\n`apps\u002Fapi\u002Fsrc\u002Findex.ts`'s own `Variables` type, because the entry globs the routes and that would\nbe a cycle.\n\n```ts\n\u002F\u002F apps\u002Fapi\u002Fsrc\u002Froutes\u002Fwidgets.ts\nimport { Hono } from \"hono\";\nimport type { LoggerVariables } from \"@repo\u002Flogger\";\n\nconst widgets = new Hono\u003C{ Variables: LoggerVariables }>();\n\nwidgets.post(\"\u002F\", async (c) => {\n  const log = c.get(\"log\");\n\n  log.info(\"creating widget\", { plan: \"pro\", seats: 5 });\n\n  try {\n    \u002F\u002F …\n  } catch (err) {\n    log.error(\"widget creation failed\", { err });\n    return c.json({ error: \"internal\" }, 500);\n  }\n\n  return c.json({ ok: true });\n});\n\nexport default widgets;\n```\n\nThe import is `@repo\u002Flogger` — the real package name — not `@logger\u002F...`. `@logger` is only the\n**file-placement alias** `saasaloy.json` uses to resolve a module's `files[].target` when copying\nfiles onto disk; it is not a TypeScript or Vite import alias.\n\n### `c.get(\"log\")` vs `createLogger(c.env)`\n\n| | what you get | use it |\n|---|---|---|\n| `c.get(\"log\")` | the request's logger, already carrying `requestId` | in any route or route middleware |\n| `createLogger(env)` | a fresh, **uncorrelated** logger | outside a request — a module-scope singleton, `scheduled()`, a queue consumer |\n\n`createLogger(env)` takes the **whole env**, not one binding, because which key the active provider\nreads is precisely what a caller isn't supposed to know. Calling it inside a route works but throws\naway the request id, which is the one thing that makes a line findable — reach for `c.get(\"log\")`\nthere.\n\n### The call shape: message first\n\n```ts\nlog.info(\"widget created\", { widgetId, plan });\n```\n\nMessage first, fields second — deliberately **not** pino's `log.info(obj, msg)`, which is an\nartifact of its printf history. There is no `%s` interpolation: compose the string yourself, and\nput values in `fields`, where a log sink can index them.\n\nSix levels, in order: `trace` · `debug` · `info` · `warn` · `error` · `fatal`. `fatal` has no\ndistinct behaviour on Workers — nothing exits the process — but it exists so a project that wants\nit doesn't have to patch the core's type.\n\n### Correlation with `child()`\n\n`log.child(fields)` returns a logger with those fields merged into every event it writes. This is\nthe whole correlation mechanism, and `apps\u002Fapi`'s middleware is one use of it:\n\n```ts\nconst requestId = c.req.header(\"cf-ray\") ?? crypto.randomUUID();\nc.set(\"log\", createLogger(c.env).child({ requestId }));\n```\n\n`cf-ray` first because it is the id Cloudflare's dashboard, invocation logs and support tickets key\non, so your line correlates with the platform's view of the same request for free; the UUID covers\nlocal dev, where there is no ray. An inbound **`x-request-id` is deliberately not honored** — it\nwould trust a client-supplied value into an indexed field, letting anyone forge or collide with a\nreal request's id. If a gateway in front of the Worker must propagate one, have the gateway\noverwrite the header, not this Worker believe it.\n\nBind more context the same way, for a unit of work inside a request:\n\n```ts\nconst jobLog = c.get(\"log\").child({ jobId, tenantId }); \u002F\u002F every line below carries all three\n```\n\nCall-site fields win over bound ones on a key collision.\n\n### Errors\n\nPass an `Error` as the `err` field. The core flattens it to `{ name, message, stack, cause? }`\nbefore any provider sees it:\n\n```ts\nlog.error(\"charge failed\", { err, invoiceId });\n```\n\nThis matters more than it looks. `name`, `message` and `stack` are all non-enumerable, so\n`JSON.stringify(new Error(\"boom\"))` is `{}` — an error logged without serialization arrives as an\nempty object. `cause` is followed **exactly one level**; a cause chain can be long or cyclic, and an\nunbounded walk is CPU the request pays for. A non-`Error` `err` (a string, a status object) is left\nin `fields` untouched rather than invented into an error shape.\n\nThere is no error class of this package's own, and `logger` never throws from a log call: a\nprovider's `write` failure is caught and swallowed. A logger that takes down a request is a\nself-inflicted outage.\n\n## Env checklist (`add logger` prints this)\n\n| Var | What | Required |\n|---|---|---|\n| `LOGGER_PROVIDER` | Which registered provider writes: `console`, … | **No** — unset selects the only installed provider |\n| `LOG_LEVEL` | Threshold: `trace` \\| `debug` \\| `info` \\| `warn` \\| `error` \\| `fatal` | No — defaults to `info` |\n\n**`LOGGER_PROVIDER` is optional on purpose, and this diverges from `EMAIL_PROVIDER` deliberately.**\nEmail has no default because a production deploy that silently stops sending is invisible. Logging\nis the opposite: its absence is its own alarm, and throwing at boot would mean the observability\nlayer caused the outage. So unset falls back to the first registered provider, no providers at all\nyields a silent no-op logger, and only a `LOGGER_PROVIDER` naming a provider that **isn't**\nregistered throws — that one is unambiguously a typo in a deploy config.\n\nAn unrecognized `LOG_LEVEL` falls back to `info` silently, for the same reason.\n\n## Reading the logs\n\n```sh\npnpm --filter @repo\u002Fapi dev   # vite dev → events print to your terminal as objects\nwrangler tail                 # a deployed Worker, live\n```\n\nIn the Cloudflare dashboard, **Workers & Pages → your Worker → Logs** queries the same stream.\n`apps\u002Fapi\u002Fwrangler.jsonc` ships the block that turns it on:\n\n```jsonc\n\"observability\": {\n  \"enabled\": true,\n  \"head_sampling_rate\": 1\n}\n```\n\n`head_sampling_rate` is the **cost dial** — `1` keeps every invocation, `0.1` keeps a tenth. Drop it\nper environment (`env.production.observability`) if log volume starts to matter. Sampling is a\nplatform feature; the logger deliberately ships no knob that would duplicate it worse.\n\n**`LOG_LEVEL` filters before anything is written**, so a line below the threshold costs nothing and\nnever reaches Workers Logs at all — it is a source-side control, not a dashboard filter. Set\n`LOG_LEVEL=debug` in dev; leave production on `info` unless you are chasing something.\n\n> [!TIP]\n> Log **objects, never pre-stringified JSON**. `log.info(\"charged\", { userId })` reaches Workers\n> Logs as queryable fields; folding the value into the message (`log.info(\"charged \" + userId)`)\n> leaves you with a text search. Individual logs cap at **256 KB** and get flagged\n> `truncated: true` past it, so keep `fields` small — don't log a whole request body.\n\n## Providers\n\n| Module | Provider name | Needs | Writes to |\n|---|---|---|---|\n| `logger-console` | `console` | nothing | `console.warn` \u002F `console.error` \u002F `console.log` by level — the Workers Logs pipeline |\n\n`logger-console` arrives automatically: `api` declares `dependsOn: [\"logger\", \"logger-console\"]`, so\n`saasaloy add api` installs all three. Installing another provider later is the same command again;\nthe codemod appends to the `providers` array idempotently, so several can be registered at once and\n`LOGGER_PROVIDER` picks between them per environment.\n\n## Redaction: what it catches, and what it does not\n\nRedaction is **on by default**. Retrofitting it after call-site habits exist is the harder order, so\nthe core does it for every event.\n\n**Caught** — a field whose key matches the deny-list, case-insensitively and exactly:\n`authorization`, `cookie`, `set-cookie`, `token`, `password`, `secret`, `api_key`. The value becomes\nthe string `[redacted]`. The walk covers the top level of `fields` **and one level below it**.\n\n**Not caught** — and each of these is a real way to leak a secret:\n\n- **A key that isn't an exact match.** `authorizationHeader`, `apiKey`, `access_token` are all\n  missed. Extend the list per project (below) rather than assuming a substring match.\n- **Anything nested more than one level deep.** `{ a: { b: { token } } }` keeps its token. The bound\n  is on purpose: an unbounded deep walk is CPU on every log call.\n- **Anything that isn't a plain object.** A `Headers`, a `Request`, a `Date`, a class instance, an\n  array of objects — all pass through whole. Pull the fields you want out first.\n- **Secrets in the message string, or in a serialized error's `message`\u002F`stack`.** Redaction is\n  key-based; it never inspects text.\n\nExtend the deny-list in `packages\u002Flogger\u002Fsrc\u002Findex.ts` — `redact` **unions** with the built-in list\nrather than replacing it:\n\n```ts\nexport const logger = defineLogger({\n  providers: [],\n  redact: [\"apiKey\", \"access_token\", \"refresh_token\", \"session\"],\n});\n```\n\nRedaction is a backstop against an accidental spread (`log.info(\"req\", { ...headers })`), not a\nlicence to log credentials. Don't put a secret in `fields` and rely on the list to catch it.\n\n## Writing a custom provider in your own project\n\nYou don't need a registry module to add a provider — a file and a line will do. Implement\n`LogProvider` in `packages\u002Flogger\u002Fsrc\u002Fproviders\u002F\u003Cname>.ts`:\n\n```ts\nimport type { LoggerEnv, LogEvent, LogProvider } from \"..\u002Fprovider\";\n\nexport function axiom(): LogProvider {\n  return {\n    name: \"axiom\", \u002F\u002F the value LOGGER_PROVIDER must hold\n    write(env: LoggerEnv, event: LogEvent): void {\n      \u002F\u002F Synchronous, returning void. Batch or ship in the background yourself; see below.\n      void fetch(\"https:\u002F\u002Fapi.axiom.co\u002Fv1\u002Fdatasets\u002Flogs\u002Fingest\", {\n        method: \"POST\",\n        headers: {\n          \"content-type\": \"application\u002Fjson\",\n          authorization: `Bearer ${String(env.AXIOM_TOKEN ?? \"\")}`,\n        },\n        body: JSON.stringify([event]),\n        signal: AbortSignal.timeout(5_000),\n      }).catch(() => {\n        \u002F\u002F Never let a shipping failure reach the caller. The core swallows throws, but a\n        \u002F\u002F rejected promise from an un-awaited fetch is yours to handle.\n      });\n    },\n  };\n}\n```\n\nThen register it by hand in `src\u002Findex.ts`:\n\n```ts\n\u002F\u002F Add the import; `defineLogger` is already imported at the top of this file.\nimport { axiom } from \".\u002Fproviders\u002Faxiom\";\n\n\u002F\u002F Then add the call to the existing array literal — don't replace the line's shape.\nexport const logger = defineLogger({ providers: [axiom()] });\n```\n\nContract notes:\n\n- **The event arrives normalized.** The level threshold has already been applied, bound and\n  call-site fields are already merged, redaction has already run, `time` is stamped, and an `Error`\n  passed as `err` is already `{ name, message, stack, cause? }`. Don't redo any of it.\n- **`write` is synchronous and returns `void`**, unlike `EmailProvider.send`. A log call is not\n  something a caller awaits, and an async `write` would either force `await log.info(...)`\n  everywhere or leak a floating promise on a Worker that may be killed before it settles. There is\n  no `ExecutionContext` argument today; widening to `createLogger(env, ctx?)` → `write(env, event,\n  ctx?)` later is non-breaking for providers written against this signature.\n- **A remote sink needs its own batching.** One `fetch` per log line is a subrequest per line, and\n  Workers cap subrequests per invocation. Buffer in the provider and flush.\n- **There is no error type to normalize into.** The core catches and swallows whatever `write`\n  throws — deliberately, because a logger that throws is a self-inflicted outage. That also means\n  a broken provider is *silent*: test it.\n- **`name` is the `LOGGER_PROVIDER` value**, unique across providers. It need not match the exported\n  factory — `logger-console`'s factory is `consoleLogger` precisely so the generated import can't\n  shadow the global `console`.\n- **Read secrets off the `env` argument**, never `process.env` (it doesn't exist on Workers), and\n  declare each one in the descriptor's `envVars` if you package it as a module.\n- Any npm dependency belongs in `packages\u002Flogger\u002Fpackage.json`, not in another workspace — only this\n  package touches provider SDKs (ADR 0020).\n\n## Removal\n\nYou cannot remove `logger` from a normal project. The `api` module declares `dependsOn: [\"logger\", \"logger-console\"]`, so `remove logger` and `remove logger-console` both refuse while `api` is installed. Only `--force` overrides the refusal, and then `apps\u002Fapi` stops compiling.\n\nA second provider is a different case. `saasaloy remove logger-\u003Cprovider>` deletes the provider file and reverses its `plugin-array` registration in the core's `providers` array. Point `LOGGER_PROVIDER` at a provider that is still installed first, or unset it.\n\nIf you do force `remove logger`, it deletes the `packages\u002Flogger` workspace (`index.ts`, `define.ts`, `provider.ts`, `env-preset.ts`) and reverses the `plugin-array` patch that adds the logger preset to `apps\u002Fapi\u002Fsrc\u002Fenv.ts`. A file you edited by hand since `add` counts as drift, and `remove` asks before it deletes it. `remove` does not edit `packages\u002Fenv\u002F.env`, so delete the `LOGGER_PROVIDER` and `LOG_LEVEL` lines by hand. Every file that imports `@repo\u002Flogger` stops compiling, and `apps\u002Fapi` is one of them.\n\n## Failure modes\n\n- `LOGGER_PROVIDER is \"\u003Cx>\", which is not registered.` thrown by `createLogger(env)`. This is the only construction error. Fix the value, or unset it to select the first registered provider.\n- No log output and no error. `LOGGER_PROVIDER` is unset and no provider is registered, so the core returns a no-op logger. Check the `providers` array in the logger's `index.ts`.\n- Debug lines do not appear. An unknown `LOG_LEVEL` falls back to `info` with no warning. Set `LOG_LEVEL` to a valid level.\n- A secret shows in a log line. Redaction matches known key names only. Read \"Redaction: what it catches, and what it does not\" above and rename or drop the field.\n\n## Boundaries to honor\n\n- **`export const logger = defineLogger({ providers: [] })` stays in exactly that shape** — a real\n  array literal, never omitted. It is the patch point every provider module appends to; without it\n  a provider install fails silently.\n- **`c.get(\"log\")` in a route, never `console.log`.** A bare console call is unlevelled,\n  uncorrelated, and skips redaction.\n- **Message first, values in `fields`.** Interpolated values can't be queried.\n- **Only `packages\u002Flogger` talks to a provider's SDK.** Everything else imports `@repo\u002Flogger`\n  (ADR 0020).\n- **A log call never throws and never blocks.** Don't add an `await`, a retry, or a `throw` to a\n  provider's `write`.\n- **`logger-console` is production.** Don't swap it out for \"something real\" — on Workers it *is*\n  the real one.\n\n## Next\n\nRun `saasaloy-api` to log from a route through `c.get(\"log\")`.\n","# logger — structured logging from `packages\u002Flogger`\n\n`packages\u002Flogger` (`@repo\u002Flogger`) is the capability core: six levels, a level threshold, child\nloggers for correlation, error serialization, key-based redaction, and a **provider registry**. It\nhas **zero runtime dependencies**. Each provider ships as its own module — today just\n`logger-console` — dropping one file into `src\u002Fproviders\u002F` and registering itself in the array in\n`src\u002Findex.ts`.\n\n> **`logger-console` is the production default, not a dev stand-in.** It shares a naming pattern\n> with `email-console` and means the opposite. On Cloudflare Workers `console.*` *is* the log\n> pipeline: Workers Logs ingests it and `wrangler tail` streams it. `email-console` logs a message\n> instead of sending it and must never be deployed; `logger-console` writes structured objects to\n> the platform's own sink and is what you ship.\n\nCallers import `@repo\u002Flogger`, or read `c.get(\"log\")` in a route, and never learn which provider is\nactive.\n\n## Log from a route\n\n`api`'s spine already mounts the correlation middleware, so a route just reads the logger off the\ncontext. Compose `LoggerVariables` into the sub-app's generic to type it — a route can't import\n`apps\u002Fapi\u002Fsrc\u002Findex.ts`'s own `Variables` type, because the entry globs the routes and that would\nbe a cycle.\n\n```ts\n\u002F\u002F apps\u002Fapi\u002Fsrc\u002Froutes\u002Fwidgets.ts\nimport { Hono } from \"hono\";\nimport type { LoggerVariables } from \"@repo\u002Flogger\";\n\nconst widgets = new Hono\u003C{ Variables: LoggerVariables }>();\n\nwidgets.post(\"\u002F\", async (c) => {\n  const log = c.get(\"log\");\n\n  log.info(\"creating widget\", { plan: \"pro\", seats: 5 });\n\n  try {\n    \u002F\u002F …\n  } catch (err) {\n    log.error(\"widget creation failed\", { err });\n    return c.json({ error: \"internal\" }, 500);\n  }\n\n  return c.json({ ok: true });\n});\n\nexport default widgets;\n```\n\nThe import is `@repo\u002Flogger` — the real package name — not `@logger\u002F...`. `@logger` is only the\n**file-placement alias** `saasaloy.json` uses to resolve a module's `files[].target` when copying\nfiles onto disk; it is not a TypeScript or Vite import alias.\n\n### `c.get(\"log\")` vs `createLogger(c.env)`\n\n| | what you get | use it |\n|---|---|---|\n| `c.get(\"log\")` | the request's logger, already carrying `requestId` | in any route or route middleware |\n| `createLogger(env)` | a fresh, **uncorrelated** logger | outside a request — a module-scope singleton, `scheduled()`, a queue consumer |\n\n`createLogger(env)` takes the **whole env**, not one binding, because which key the active provider\nreads is precisely what a caller isn't supposed to know. Calling it inside a route works but throws\naway the request id, which is the one thing that makes a line findable — reach for `c.get(\"log\")`\nthere.\n\n### The call shape: message first\n\n```ts\nlog.info(\"widget created\", { widgetId, plan });\n```\n\nMessage first, fields second — deliberately **not** pino's `log.info(obj, msg)`, which is an\nartifact of its printf history. There is no `%s` interpolation: compose the string yourself, and\nput values in `fields`, where a log sink can index them.\n\nSix levels, in order: `trace` · `debug` · `info` · `warn` · `error` · `fatal`. `fatal` has no\ndistinct behaviour on Workers — nothing exits the process — but it exists so a project that wants\nit doesn't have to patch the core's type.\n\n### Correlation with `child()`\n\n`log.child(fields)` returns a logger with those fields merged into every event it writes. This is\nthe whole correlation mechanism, and `apps\u002Fapi`'s middleware is one use of it:\n\n```ts\nconst requestId = c.req.header(\"cf-ray\") ?? crypto.randomUUID();\nc.set(\"log\", createLogger(c.env).child({ requestId }));\n```\n\n`cf-ray` first because it is the id Cloudflare's dashboard, invocation logs and support tickets key\non, so your line correlates with the platform's view of the same request for free; the UUID covers\nlocal dev, where there is no ray. An inbound **`x-request-id` is deliberately not honored** — it\nwould trust a client-supplied value into an indexed field, letting anyone forge or collide with a\nreal request's id. If a gateway in front of the Worker must propagate one, have the gateway\noverwrite the header, not this Worker believe it.\n\nBind more context the same way, for a unit of work inside a request:\n\n```ts\nconst jobLog = c.get(\"log\").child({ jobId, tenantId }); \u002F\u002F every line below carries all three\n```\n\nCall-site fields win over bound ones on a key collision.\n\n### Errors\n\nPass an `Error` as the `err` field. The core flattens it to `{ name, message, stack, cause? }`\nbefore any provider sees it:\n\n```ts\nlog.error(\"charge failed\", { err, invoiceId });\n```\n\nThis matters more than it looks. `name`, `message` and `stack` are all non-enumerable, so\n`JSON.stringify(new Error(\"boom\"))` is `{}` — an error logged without serialization arrives as an\nempty object. `cause` is followed **exactly one level**; a cause chain can be long or cyclic, and an\nunbounded walk is CPU the request pays for. A non-`Error` `err` (a string, a status object) is left\nin `fields` untouched rather than invented into an error shape.\n\nThere is no error class of this package's own, and `logger` never throws from a log call: a\nprovider's `write` failure is caught and swallowed. A logger that takes down a request is a\nself-inflicted outage.\n\n## Env checklist (`add logger` prints this)\n\n| Var | What | Required |\n|---|---|---|\n| `LOGGER_PROVIDER` | Which registered provider writes: `console`, … | **No** — unset selects the only installed provider |\n| `LOG_LEVEL` | Threshold: `trace` \\| `debug` \\| `info` \\| `warn` \\| `error` \\| `fatal` | No — defaults to `info` |\n\n**`LOGGER_PROVIDER` is optional on purpose, and this diverges from `EMAIL_PROVIDER` deliberately.**\nEmail has no default because a production deploy that silently stops sending is invisible. Logging\nis the opposite: its absence is its own alarm, and throwing at boot would mean the observability\nlayer caused the outage. So unset falls back to the first registered provider, no providers at all\nyields a silent no-op logger, and only a `LOGGER_PROVIDER` naming a provider that **isn't**\nregistered throws — that one is unambiguously a typo in a deploy config.\n\nAn unrecognized `LOG_LEVEL` falls back to `info` silently, for the same reason.\n\n## Reading the logs\n\n```sh\npnpm --filter @repo\u002Fapi dev   # vite dev → events print to your terminal as objects\nwrangler tail                 # a deployed Worker, live\n```\n\nIn the Cloudflare dashboard, **Workers & Pages → your Worker → Logs** queries the same stream.\n`apps\u002Fapi\u002Fwrangler.jsonc` ships the block that turns it on:\n\n```jsonc\n\"observability\": {\n  \"enabled\": true,\n  \"head_sampling_rate\": 1\n}\n```\n\n`head_sampling_rate` is the **cost dial** — `1` keeps every invocation, `0.1` keeps a tenth. Drop it\nper environment (`env.production.observability`) if log volume starts to matter. Sampling is a\nplatform feature; the logger deliberately ships no knob that would duplicate it worse.\n\n**`LOG_LEVEL` filters before anything is written**, so a line below the threshold costs nothing and\nnever reaches Workers Logs at all — it is a source-side control, not a dashboard filter. Set\n`LOG_LEVEL=debug` in dev; leave production on `info` unless you are chasing something.\n\n> [!TIP]\n> Log **objects, never pre-stringified JSON**. `log.info(\"charged\", { userId })` reaches Workers\n> Logs as queryable fields; folding the value into the message (`log.info(\"charged \" + userId)`)\n> leaves you with a text search. Individual logs cap at **256 KB** and get flagged\n> `truncated: true` past it, so keep `fields` small — don't log a whole request body.\n\n## Providers\n\n| Module | Provider name | Needs | Writes to |\n|---|---|---|---|\n| `logger-console` | `console` | nothing | `console.warn` \u002F `console.error` \u002F `console.log` by level — the Workers Logs pipeline |\n\n`logger-console` arrives automatically: `api` declares `dependsOn: [\"logger\", \"logger-console\"]`, so\n`saasaloy add api` installs all three. Installing another provider later is the same command again;\nthe codemod appends to the `providers` array idempotently, so several can be registered at once and\n`LOGGER_PROVIDER` picks between them per environment.\n\n## Redaction: what it catches, and what it does not\n\nRedaction is **on by default**. Retrofitting it after call-site habits exist is the harder order, so\nthe core does it for every event.\n\n**Caught** — a field whose key matches the deny-list, case-insensitively and exactly:\n`authorization`, `cookie`, `set-cookie`, `token`, `password`, `secret`, `api_key`. The value becomes\nthe string `[redacted]`. The walk covers the top level of `fields` **and one level below it**.\n\n**Not caught** — and each of these is a real way to leak a secret:\n\n- **A key that isn't an exact match.** `authorizationHeader`, `apiKey`, `access_token` are all\n  missed. Extend the list per project (below) rather than assuming a substring match.\n- **Anything nested more than one level deep.** `{ a: { b: { token } } }` keeps its token. The bound\n  is on purpose: an unbounded deep walk is CPU on every log call.\n- **Anything that isn't a plain object.** A `Headers`, a `Request`, a `Date`, a class instance, an\n  array of objects — all pass through whole. Pull the fields you want out first.\n- **Secrets in the message string, or in a serialized error's `message`\u002F`stack`.** Redaction is\n  key-based; it never inspects text.\n\nExtend the deny-list in `packages\u002Flogger\u002Fsrc\u002Findex.ts` — `redact` **unions** with the built-in list\nrather than replacing it:\n\n```ts\nexport const logger = defineLogger({\n  providers: [],\n  redact: [\"apiKey\", \"access_token\", \"refresh_token\", \"session\"],\n});\n```\n\nRedaction is a backstop against an accidental spread (`log.info(\"req\", { ...headers })`), not a\nlicence to log credentials. Don't put a secret in `fields` and rely on the list to catch it.\n\n## Writing a custom provider in your own project\n\nYou don't need a registry module to add a provider — a file and a line will do. Implement\n`LogProvider` in `packages\u002Flogger\u002Fsrc\u002Fproviders\u002F\u003Cname>.ts`:\n\n```ts\nimport type { LoggerEnv, LogEvent, LogProvider } from \"..\u002Fprovider\";\n\nexport function axiom(): LogProvider {\n  return {\n    name: \"axiom\", \u002F\u002F the value LOGGER_PROVIDER must hold\n    write(env: LoggerEnv, event: LogEvent): void {\n      \u002F\u002F Synchronous, returning void. Batch or ship in the background yourself; see below.\n      void fetch(\"https:\u002F\u002Fapi.axiom.co\u002Fv1\u002Fdatasets\u002Flogs\u002Fingest\", {\n        method: \"POST\",\n        headers: {\n          \"content-type\": \"application\u002Fjson\",\n          authorization: `Bearer ${String(env.AXIOM_TOKEN ?? \"\")}`,\n        },\n        body: JSON.stringify([event]),\n        signal: AbortSignal.timeout(5_000),\n      }).catch(() => {\n        \u002F\u002F Never let a shipping failure reach the caller. The core swallows throws, but a\n        \u002F\u002F rejected promise from an un-awaited fetch is yours to handle.\n      });\n    },\n  };\n}\n```\n\nThen register it by hand in `src\u002Findex.ts`:\n\n```ts\n\u002F\u002F Add the import; `defineLogger` is already imported at the top of this file.\nimport { axiom } from \".\u002Fproviders\u002Faxiom\";\n\n\u002F\u002F Then add the call to the existing array literal — don't replace the line's shape.\nexport const logger = defineLogger({ providers: [axiom()] });\n```\n\nContract notes:\n\n- **The event arrives normalized.** The level threshold has already been applied, bound and\n  call-site fields are already merged, redaction has already run, `time` is stamped, and an `Error`\n  passed as `err` is already `{ name, message, stack, cause? }`. Don't redo any of it.\n- **`write` is synchronous and returns `void`**, unlike `EmailProvider.send`. A log call is not\n  something a caller awaits, and an async `write` would either force `await log.info(...)`\n  everywhere or leak a floating promise on a Worker that may be killed before it settles. There is\n  no `ExecutionContext` argument today; widening to `createLogger(env, ctx?)` → `write(env, event,\n  ctx?)` later is non-breaking for providers written against this signature.\n- **A remote sink needs its own batching.** One `fetch` per log line is a subrequest per line, and\n  Workers cap subrequests per invocation. Buffer in the provider and flush.\n- **There is no error type to normalize into.** The core catches and swallows whatever `write`\n  throws — deliberately, because a logger that throws is a self-inflicted outage. That also means\n  a broken provider is *silent*: test it.\n- **`name` is the `LOGGER_PROVIDER` value**, unique across providers. It need not match the exported\n  factory — `logger-console`'s factory is `consoleLogger` precisely so the generated import can't\n  shadow the global `console`.\n- **Read secrets off the `env` argument**, never `process.env` (it doesn't exist on Workers), and\n  declare each one in the descriptor's `envVars` if you package it as a module.\n- Any npm dependency belongs in `packages\u002Flogger\u002Fpackage.json`, not in another workspace — only this\n  package touches provider SDKs (ADR 0020).\n\n## Removal\n\nYou cannot remove `logger` from a normal project. The `api` module declares `dependsOn: [\"logger\", \"logger-console\"]`, so `remove logger` and `remove logger-console` both refuse while `api` is installed. Only `--force` overrides the refusal, and then `apps\u002Fapi` stops compiling.\n\nA second provider is a different case. `saasaloy remove logger-\u003Cprovider>` deletes the provider file and reverses its `plugin-array` registration in the core's `providers` array. Point `LOGGER_PROVIDER` at a provider that is still installed first, or unset it.\n\nIf you do force `remove logger`, it deletes the `packages\u002Flogger` workspace (`index.ts`, `define.ts`, `provider.ts`, `env-preset.ts`) and reverses the `plugin-array` patch that adds the logger preset to `apps\u002Fapi\u002Fsrc\u002Fenv.ts`. A file you edited by hand since `add` counts as drift, and `remove` asks before it deletes it. `remove` does not edit `packages\u002Fenv\u002F.env`, so delete the `LOGGER_PROVIDER` and `LOG_LEVEL` lines by hand. Every file that imports `@repo\u002Flogger` stops compiling, and `apps\u002Fapi` is one of them.\n\n## Failure modes\n\n- `LOGGER_PROVIDER is \"\u003Cx>\", which is not registered.` thrown by `createLogger(env)`. This is the only construction error. Fix the value, or unset it to select the first registered provider.\n- No log output and no error. `LOGGER_PROVIDER` is unset and no provider is registered, so the core returns a no-op logger. Check the `providers` array in the logger's `index.ts`.\n- Debug lines do not appear. An unknown `LOG_LEVEL` falls back to `info` with no warning. Set `LOG_LEVEL` to a valid level.\n- A secret shows in a log line. Redaction matches known key names only. Read \"Redaction: what it catches, and what it does not\" above and rename or drop the field.\n\n## Boundaries to honor\n\n- **`export const logger = defineLogger({ providers: [] })` stays in exactly that shape** — a real\n  array literal, never omitted. It is the patch point every provider module appends to; without it\n  a provider install fails silently.\n- **`c.get(\"log\")` in a route, never `console.log`.** A bare console call is unlevelled,\n  uncorrelated, and skips redaction.\n- **Message first, values in `fields`.** Interpolated values can't be queried.\n- **Only `packages\u002Flogger` talks to a provider's SDK.** Everything else imports `@repo\u002Flogger`\n  (ADR 0020).\n- **A log call never throws and never blocks.** Don't add an `await`, a retry, or a `throw` to a\n  provider's `write`.\n- **`logger-console` is production.** Don't swap it out for \"something real\" — on Workers it *is*\n  the real one.\n\n## Next\n\nRun `saasaloy-api` to log from a route through `c.get(\"log\")`.\n",{"name":5,"description":7},"main","a46a4dd388795519840da0ed1f695634b6dcd99b","modules\u002Flogger\u002Fskills\u002Fsaasaloy-logger",0,"https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy","https:\u002F\u002Fsaasaloy.com","https:\u002F\u002Fgithub.com\u002Fmimukit","https:\u002F\u002Fmimukit.com","Senior Software Engineer · 9+ yrs Fullstack (TS\u002FNode\u002FReact) · AI integrations, distributed systems · Building @saasaloy & @codealoy · Bangladesh 🇧🇩 \u002F Remote","2026-11-13 20:39:28",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add mimukit\u002Fsaasaloy --skill saasaloy-logger",{"tool":40,"command":41},"bunx","bunx skills add mimukit\u002Fsaasaloy --skill saasaloy-logger",{"tool":43,"command":44},"pnpm","pnpm dlx skills add mimukit\u002Fsaasaloy --skill saasaloy-logger","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fmodules\u002Flogger\u002Fskills\u002Fsaasaloy-logger\u002FSKILL.md",true,[],[49,56,63,70,77,83],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":53,"categories":54,"keywords":55,"publishedAt":19},"01M7BE75C34XHSPVJNQC8FY4Q0","saasaloy-subscription","Runbook for the subscription capability — provider-agnostic subscriptions in packages\u002Fsubscription, with a plan file, a projection table, a billable-subject file, plan entitlements and per-provider modules. Use when adding a plan, adding a plan feature or a numeric limit, gating an API route with requireFeature or requireWithinLimit, reading the 402 it returns, working out why a subject resolves to the free plan, wiring a checkout or portal route, reading a SubscriptionError, choosing or switching SUBSCRIPTION_PROVIDER, registering a webhook in the vendor's dashboard, writing a third subscription provider, or upgrading a project that still has `billing` installed.","https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fmodules\u002Fsubscription\u002Fskills\u002Fsaasaloy-subscription\u002FSKILL.md",[],[],{"skillNo":57,"name":58,"nameZh":6,"description":59,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":60,"categories":61,"keywords":62,"publishedAt":19},"01M7BE68MJ8H47JZKTBDFYR6JD","saasaloy-notification","Runbook for the notification module, in-app notifications for apps\u002Fapp. It owns the notifications and notification_opt_outs tables, notify() in apps\u002Fapi\u002Fsrc\u002Flib\u002Fnotify.ts, the \u002Fnotifications api routes, the bell in the app header, the sidebar badge, the \u002Fnotifications page with Inbox and Preferences tabs, the notification config section, and the daily prune. Use when sending a notification from an api route, adding or changing a category, changing retention, debugging a badge or bell count that does not move, or removing the module.","https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fmodules\u002Fnotification\u002Fskills\u002Fsaasaloy-notification\u002FSKILL.md",[],[],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7BE53PDQV0YDPG8RNVGTPEQ","saasaloy-cms","Runbook for the cms module, the in-house CMS behind apps\u002Fadmin. Covers code-defined collections, the Tiptap editor, drafts, revisions and redirects, the publish-time renderer, the public blog on apps\u002Fweb and its 60-second cache. Use when adding a collection or a field, rendering a stored body, reusing the editor, renderer or media field from another module, moving the blog to another path, re-rendering live posts after a renderer upgrade or a STORAGE_PUBLIC_URL change, or working out why a published post is not live yet.","https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fmodules\u002Fcms\u002Fskills\u002Fsaasaloy-cms\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M79GQ03M63V5EKSST92B3S5X","saasaloy-beta","The beta module's own procedure.","https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fpackages\u002Fcli\u002Ftest\u002Ffixtures\u002Fregistry-clean\u002Fbeta\u002Fsaasaloy-beta\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M79GPXV3K8YF3M4VA0KGVE0B","helper","https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fpackages\u002Fcli\u002Ftest\u002Ffixtures\u002Fregistry-broken\u002Fbad-skill\u002Fhelper\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M79GPR8EVS1YX0W8X33Q9YD8","saasaloy-update","Runbook for an AI agent that updates this project to a newer Saasaloy CLI and newer module versions with saasaloy update. Use when the owner says \"update saasaloy\", \"upgrade the CLI\", \"pull the latest modules\", \"update the base template\", \"work the merge plan\", \"clear the update notes\", when saasaloy update or saasaloy outdated --check exits 3 or 2, when a merge plan or .saasaloy\u002Fmerge-plan.md is handed to you, or when an adopted project takes its first update. Covers the CLI upgrade, the preview, --out, the file merges, the update notes and \"Notes that may apply\", --resolved and --done, a file deleted locally and --restore, a three-way or two-way base, an update that skips releases, --from, the verify commands, and the exit codes.","https:\u002F\u002Fgithub.com\u002Fmimukit\u002Fsaasaloy\u002Fblob\u002Fmain\u002Fpackages\u002Fcli\u002Ftemplates\u002Fbase\u002F_agents\u002Fskills\u002Fsaasaloy-update\u002FSKILL.md",[],[]]