Skip to content

Commit b30eee8

Browse files
authored
Set LOG_LEVEL=debug with ITERABLE_DEBUG (#18)
1 parent 197f21a commit b30eee8

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const client = new IterableClient({
2323
apiKey: 'your-api-key'
2424
});
2525

26-
const user = await client.getUserByEmail('user@example.com');
26+
const user = await client.getUserByEmail({ email: 'user@example.com' });
2727

2828
// Track event
2929
await client.trackEvent({
@@ -57,13 +57,15 @@ const client = new IterableClient({
5757

5858
### Environment Variables
5959

60-
```bash
61-
ITERABLE_API_KEY=your-api-key # Required
62-
ITERABLE_DEBUG=true # Enable basic debug logging
63-
ITERABLE_DEBUG_VERBOSE=true # Enable full body logging (includes PII)
64-
LOG_LEVEL=info # Log level
65-
LOG_FILE=./logs/iterable.log # Log to file
66-
```
60+
| Variable | Description | Default |
61+
|----------|-------------|---------|
62+
| `ITERABLE_API_KEY` | API key (required when using `createIterableConfig()`) ||
63+
| `ITERABLE_BASE_URL` | API base URL | `https://api.iterable.com` |
64+
| `ITERABLE_DEBUG` | Log HTTP requests/responses (headers redacted) to stderr | `false` |
65+
| `ITERABLE_DEBUG_VERBOSE` | Include response bodies in debug output (may contain PII) | `false` |
66+
| `LOG_LEVEL` | Log level (`error`, `warn`, `info`, `debug`, etc.) | `debug` when `ITERABLE_DEBUG` is set, otherwise `info` |
67+
| `LOG_FILE` | Write logs to a file ||
68+
| `LOG_STDERR` | Write logs to stderr | `true` |
6769

6870
## Development
6971

src/config.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ export const config = createEnv({
2020
LOG_LEVEL: z
2121
.enum(["error", "warn", "info", "http", "verbose", "debug", "silly"])
2222
.default(
23-
!process.env.NODE_ENV || process.env.NODE_ENV === "production"
24-
? "info"
25-
: "debug"
23+
process.env.ITERABLE_DEBUG === "true" ||
24+
process.env.ITERABLE_DEBUG_VERBOSE === "true"
25+
? "debug"
26+
: !process.env.NODE_ENV || process.env.NODE_ENV === "production"
27+
? "info"
28+
: "debug"
2629
),
2730
LOG_JSON: z.coerce.boolean().default(process.env.NODE_ENV === "production"),
2831
LOG_FILE: z.string().optional(),

0 commit comments

Comments
 (0)