# Logs

What happened, told to whoever runs the app. Recorded with [`log()`](https://www.prongs.dev/docs/profiles/logs.md).

Written with: [`log()`](https://www.prongs.dev/docs/profiles/logs.md) · Added with: `npx prongs add logs` · Domains: [5](#domains) · Intents: [13](#domains)

## Domains

- [`audit.*`](https://www.prongs.dev/docs/intents/audit.md) Audit: Who did what, kept as a record: things created, changed, deleted, and changes to access. (info; 5 intents)
- [`security.*`](https://www.prongs.dev/docs/intents/security.md) Security: Signals worth watching: failed sign-ins, bad tokens, rate limits, probing. (warn; 3 intents)
- [`incident.*`](https://www.prongs.dev/docs/intents/incident.md) Incident: Something broke or degraded, and someone should look. (error, warn; 2 intents)
- [`job.*`](https://www.prongs.dev/docs/intents/job.md) Job: Background work: syncs, backups, migrations, scheduled runs. (info; 2 intents)
- [`debug.*`](https://www.prongs.dev/docs/intents/debug.md) Debug: Detail for working on the code, dropped in production. (debug; 1 intent)

## Recording one

`log(intent, message, data?)` writes one structured entry. Name what happened; the intent sets the level and whether it alerts. [Read the guide](https://www.prongs.dev/docs/profiles/logs.md).

```ts
// Someone created something that matters later: an account, a page, an API key
log('audit.created', 'Page created', { pageId: 'p_123', by: 'u_42' });

// Someone changed something that matters: settings, a role, a published page
log('audit.changed', 'Page settings saved', { pageId: 'p_123', fields: 'theme' });

// Someone deleted something: a page, an account, content
log('audit.deleted', 'Page deleted', { pageId: 'p_123', by: 'u_42' });

// Someone signed in, the ordinary way
log('audit.signedin', 'Something happened', {  });

// Someone signed out
log('audit.signedout', 'Something happened', {  });
```

## Looks

The levels log intents are built from. Change a level here and every entry built from it follows. Looks have no pages of their own; each is listed here with what it is built from and the intents built from it.

### [`level.*`](https://www.prongs.dev/docs/intents/logs.md#level)
- [`level.error`](https://www.prongs.dev/docs/intents/logs.md#level-error): Error level: something is broken
  - Used to build: [`incident.failed`](https://www.prongs.dev/docs/intents/incident/failed.md)
- [`level.warn`](https://www.prongs.dev/docs/intents/logs.md#level-warn): Warning level: worth a look, not broken
  - Used to build: [`security.signin`](https://www.prongs.dev/docs/intents/security/signin.md), [`security.token`](https://www.prongs.dev/docs/intents/security/token.md), [`security.limited`](https://www.prongs.dev/docs/intents/security/limited.md), [`incident.degraded`](https://www.prongs.dev/docs/intents/incident/degraded.md)
- [`level.info`](https://www.prongs.dev/docs/intents/logs.md#level-info): Info level: a record of something that happened
  - Used to build: [`audit.created`](https://www.prongs.dev/docs/intents/audit/created.md), [`audit.changed`](https://www.prongs.dev/docs/intents/audit/changed.md), [`audit.deleted`](https://www.prongs.dev/docs/intents/audit/deleted.md), [`audit.signedin`](https://www.prongs.dev/docs/intents/audit/signedin.md), [`audit.signedout`](https://www.prongs.dev/docs/intents/audit/signedout.md), [`job.started`](https://www.prongs.dev/docs/intents/job/started.md), [`job.finished`](https://www.prongs.dev/docs/intents/job/finished.md)
- [`level.debug`](https://www.prongs.dev/docs/intents/logs.md#level-debug): Debug level: detail for development, dropped in production
  - Used to build: [`debug.trace`](https://www.prongs.dev/docs/intents/debug/trace.md)

## For registry authors

**Starter intents.** These are the intents `prongs add logs` puts in your registry. Change levels through the [`level.*`](https://www.prongs.dev/docs/intents/logs.md#level) intents, and point [`log()`](https://www.prongs.dev/docs/profiles/logs.md) at your logger.
