# Debug Logging Without a Redeploy

Production runs at `info` for good reasons: debug lines are loud and they cost money. But when one customer hits a
bug you can't reproduce, you want their debug lines, now, and only theirs. Turning the level down for everyone means a
deploy, a flood of lines and a second deploy to undo it.

So Tailcove lets you turn debug logging on for a slice of your traffic, for a set time, from the source's page:

- **one user**: lines logged while user `42` is signed in, or that carry `user_id: 42`;
- **one host**: lines from `web-3`;
- **requests to a path**: lines logged while serving `/checkout` and anything under it;
- **a field value**: lines whose context has `tenant_id = acme`;
- **everything**: every line, for when the whole source needs it.

Each one lasts 5 minutes to 4 hours and ends by itself. Your apps pick it up within 30 seconds and go back to their
own level when the time is up, even if they can't reach Tailcove at that moment.

## Turn it on

1. Open the source and stay on its **Overview**.
2. In **Debug logging**, choose the level (`debug`), what it applies to, the value and for how long.
3. Choose **Start**. The card lists what is on, who started it and when it ends. **Stop** ends one early.

From a script or CI, use the [API](https://tailcove.dev/docs/api/sources): `POST /api/v1/sources/{id}/log-levels` with a token that has
`sources:write`:

```bash
curl -X POST https://tailcove.dev/api/v1/sources/src_01jbx5q8k7m3n2p4r6s8t0v1w3/log-levels \
  -H "Authorization: Bearer $TAILCOVE_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"level": "debug", "type": "user", "value": "42", "minutes": 15, "reason": "ticket 8812"}'
```

## Set up your app

The Tailcove clients do this for you from their next release; there is nothing to install beyond the client itself.
Keep your app's level where it is and let the override lower it:

| Client | Level setting | A line matches a user through |
| ------ | ------------- | ----------------------------- |
| [Laravel](https://tailcove.dev/docs/sending-logs/laravel-package) | `TAILCOVE_LEVEL=info` | the signed-in user, or `user_id` in the context |
| [Node.js](https://tailcove.dev/docs/sending-logs/node) | `level: 'info'` | `user_id`, `userId` or `user.id` in the context |
| [Python](https://tailcove.dev/docs/sending-logs/python) | `TailcoveHandler(level=logging.INFO)` | `user_id` or `userId` in `extra` |

Your logger still decides which lines reach the client. With pino, winston or Python's `logging`, set the logger
itself to `debug` and the Tailcove level to `info`, so debug lines reach Tailcove's client and it decides.

A path matches the request being served (Laravel) or a `path`, `url` or `route` field in the line's context (Node.js
and Python). A field matches a context field of that name.

## What it costs

Lines sent under an override are ordinary lines: they count toward your plan's volume like any other. That's why each
override has an end, and why it can be as narrow as one user. A source can have up to 10 on at once.

The clients ask Tailcove for the overrides at most every 30 seconds, and the Laravel package only when a line below
its level is logged. The answer is cached on our side, so it costs nothing measurable, and a client that can't reach
Tailcove simply keeps sending what it would have sent anyway. Turn polling off with `TAILCOVE_LOG_LEVELS=false`
(Laravel), `logLevels: false` (Node.js) or `log_levels=False` (Python).
