Timestamps for logs #3

Closed
opened 2026-07-13 20:13:12 +00:00 by alex · 2 comments
Owner

See what options Deno std provides for logging

See what options Deno std provides for logging
Author
Owner

/pi new report

/pi new report
Contributor

Let me investigate what Deno std's @std/log module provides, particularly regarding timestamp formatting.Now I have a thorough understanding. Let me compile the findings into a report. The key finding is that Deno std's @std/log provides a LogRecord with a datetime field and custom formatter functions for handlers, but does not have a built-in timestamp formatter — you must supply your own.Now let me create a PR with the report:Report created in PR #4.

Summary of findings:

Deno std's @std/log (v0.224.14) does capture timestamps — every LogRecord has a datetime: Date field set at the moment of the log call. However, it does not provide a built-in formatter that renders that timestamp as a human-readable string:

  • The default formatter ignores the timestamp entirely ("INFO Hello, world!").
  • The jsonFormatter includes it, but only as epoch milliseconds (1783973885167).

To get a readable timestamp, you supply a custom formatter function to ConsoleHandler or FileHandler. The report documents 5 approaches, with ISO 8601 via r.datetime.toISOString() recommended as the simplest and most robust:

[2026-07-13T20:17:41.496Z] [INFO] Connecting to irc.libera.chat:6697...
[2026-07-13T20:17:41.497Z] [WARN] Something is amiss
[2026-07-13T20:17:41.498Z] [ERROR] Something broke

The migration would be mechanical: one setup() call at startup, then replace each console.info/console.error with logger.info/logger.error.


View action run | Model: zai/glm-5.2 (thinking: max) | Time: 3m 10s | Tokens: 386.7K | Pi SDK v0.80.6 | Action v2.25.1-develop (develop @ 9c24480)

Let me investigate what Deno std's `@std/log` module provides, particularly regarding timestamp formatting.Now I have a thorough understanding. Let me compile the findings into a report. The key finding is that Deno std's `@std/log` provides a `LogRecord` with a `datetime` field and custom `formatter` functions for handlers, but does **not** have a built-in timestamp formatter — you must supply your own.Now let me create a PR with the report:Report created in PR #4. **Summary of findings:** Deno std's `@std/log` (v0.224.14) **does** capture timestamps — every `LogRecord` has a `datetime: Date` field set at the moment of the log call. However, it **does not** provide a built-in formatter that renders that timestamp as a human-readable string: - The **default formatter** ignores the timestamp entirely (`"INFO Hello, world!"`). - The **`jsonFormatter`** includes it, but only as epoch milliseconds (`1783973885167`). To get a readable timestamp, you supply a custom `formatter` function to `ConsoleHandler` or `FileHandler`. The report documents 5 approaches, with **ISO 8601 via `r.datetime.toISOString()`** recommended as the simplest and most robust: ``` [2026-07-13T20:17:41.496Z] [INFO] Connecting to irc.libera.chat:6697... [2026-07-13T20:17:41.497Z] [WARN] Something is amiss [2026-07-13T20:17:41.498Z] [ERROR] Something broke ``` The migration would be mechanical: one `setup()` call at startup, then replace each `console.info`/`console.error` with `logger.info`/`logger.error`. --- [View action run](https://forge.l3x.in/alex/irc-horsegift-greeter/actions/runs/9) | Model: zai/glm-5.2 (thinking: max) | Time: 3m 10s | Tokens: 386.7K | Pi SDK v0.80.6 | Action v2.25.1-develop (develop @ 9c24480)
alex closed this issue 2026-07-14 02:02:12 +00:00
Sign in to join this conversation.
No labels
dependencies
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
alex/irc-greeter-bot#3
No description provided.