about summary refs log tree commit diff
path: root/src/logger/README.md
blob: e3476efdf614b86a601a44b505dc9457a607826c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Logger

Simple logger for Bluesky.

## At a Glance

```typescript
import { logger, Logger } from '#/logger'

// or, optionally create new instance with custom context
// const logger = Logger.create(Logger.Context.Notifications)

// for dev-only logs
logger.debug(message, {})

// for production breadcrumbs
logger.info(message, {})

// seldom used, prefer `info`
logger.log(message, {})

// for non-error issues to look into, seldom used, prefer `error`
logger.warn(message, {})

// for known errors without an exception, use a string
logger.error(`known error`, {})

// for unknown exceptions
try {
} catch (e) {
  logger.error(e, {message: `explain error`}])
}
```

#### Log Levels

Log level defaults to `info`. You can set this via the `EXPO_PUBLIC_LOG_LEVEL`
env var in `.env.local`.

#### Filtering debugs by context

Debug logs are dev-only, and not enabled by default. Once enabled, they can get
noisy. So you can filter them by setting the `EXPO_PUBLIC_LOG_DEBUG` env var
e.g. `EXPO_PUBLIC_LOG_DEBUG=notifications`. These values can be comma-separated
and include wildcards.