You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e368e08
Browse filesBrowse the repository at this point in the historyBrowse files
feat: improve structured logging with environment-based formatting and verbosity levels (#534)
# Improved Structured Logging for Better Developer Experience
This PR enhances the logging system in Edge Worker with significant developer experience improvements:
- Added a new `verbose` log level between `info` and `debug` for task outcomes
- Implemented environment detection to automatically set appropriate defaults:
- Local development: Colorful "fancy" format at `verbose` level
- Hosted environments: Structured key=value format at `info` level
- Created two formatter types:
- Fancy formatter with colored icons, worker-prefixed lines, and flow/step paths
- Simple formatter with structured key=value output optimized for log aggregators
- Added task duration display and retry information with exponential backoff delay calculation
- Added support for the NO_COLOR standard
- Introduced environment variable controls:
- `EDGE_WORKER_LOG_LEVEL` to set verbosity
- `EDGE_WORKER_LOG_FORMAT` to choose output style
The documentation has been updated with comprehensive logging configuration details, examples of both output formats, and a clearer explanation of the log level hierarchy.
Copy file name to clipboardExpand all lines: pkgs/website/src/content/docs/deploy/monitor-workers-health.mdx
+15-9Lines changed: 15 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,22 +7,28 @@ sidebar:
7
7
8
8
## Logging
9
9
10
-
Edge Worker logs various events to the console. You can change the log level
11
-
by setting `EDGE_WORKER_LOG_LEVEL` environment variable:
10
+
Edge Worker automatically configures logging based on your environment:
11
+
-**Local development**: Colorful "fancy" format at `verbose` level
12
+
-**Hosted Supabase**: Structured key=value format at `info` level
13
+
14
+
You can override the log level by setting `EDGE_WORKER_LOG_LEVEL`:
12
15
13
16
```bash
14
-
// supabase/functions/.env
17
+
# supabase/functions/.env
15
18
EDGE_WORKER_LOG_LEVEL=debug
16
19
```
17
20
18
-
Available log levels are:
21
+
Available log levels (from least to most verbose):
19
22
20
-
-`debug`
21
-
-`info`
22
-
-`error`
23
-
- (more will come)
23
+
| Level | Description |
24
+
|-------|-------------|
25
+
|`error`| Critical failures only |
26
+
|`warn`| Deprecation notices, auth failures |
27
+
|`info`| Startup banner, shutdown events |
28
+
|`verbose`| Task outcomes, polling feedback |
29
+
|`debug`| Task started events, detailed identifiers |
24
30
25
-
By default, Edge Worker's log level is `info`.
31
+
For complete logging configuration including output format options and examples, see [Worker Logging Configuration](/reference/configuration/worker/#logging-configuration).
Copy file name to clipboardExpand all lines: pkgs/website/src/content/docs/reference/configuration/worker.mdx
+57Lines changed: 57 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,6 +117,63 @@ How frequently (in milliseconds) to check the database for new tasks during the
117
117
118
118
Your flow step handlers can access the resolved worker configuration through the context object. For detailed information about available configuration options and usage patterns, see [`workerConfig`](/reference/context/#workerconfig).
119
119
120
+
## Logging Configuration
121
+
122
+
Edge Worker automatically configures logging based on your environment, but you can override the defaults with environment variables.
When using Edge Worker in [Background Jobs Mode](/get-started/faq/#what-are-the-two-edge-worker-modes) (without pgflow orchestration), there are a few key differences:
0 commit comments