Skip to content

feat(logs): colorize log lines using structured severity field#144

Merged
AdrianLC merged 4 commits intomainfrom
adrian/logs-severity-colorize
Apr 13, 2026
Merged

feat(logs): colorize log lines using structured severity field#144
AdrianLC merged 4 commits intomainfrom
adrian/logs-severity-colorize

Conversation

@AdrianLC
Copy link
Copy Markdown
Contributor

@AdrianLC AdrianLC commented Apr 9, 2026

Summary

  • Replaces the regex-based log level colorizer with one that uses the severity field from the structured ServiceLogEntry
  • Only the severity token (e.g. ERROR:) is colorized within the line — not the full line — preserving the original behaviour that's easier on the eyes across different terminal color schemes
  • Using the API-provided severity field eliminates false matches: the old regex would colorize any word matching a severity name anywhere in the message body (e.g. a query mentioning WARNING or ERROR), whereas now only the actual severity of that log entry is colorized
  • Severity levels follow the PostgreSQL spec: https://www.postgresql.org/docs/current/runtime-config-logging.html#RUNTIME-CONFIG-SEVERITY-LEVELS

Merge order

Depends on #143 (which introduces the structured ServiceLogEntry with the severity field). Merge that first.

@AdrianLC AdrianLC requested a review from Askir April 9, 2026 11:43
Base automatically changed from adrian/logs-cursor-pagination to main April 9, 2026 15:45
@AdrianLC AdrianLC marked this pull request as ready for review April 9, 2026 16:00
Replace the regex-based log level parser with direct use of the
severity field from the structured ServiceLogEntry. Colorization now
applies to the full log line based on the severity value rather than
scanning the message text for embedded level tokens.

Removes the logLevelRegex and colorizeLogLine helpers entirely.
Use the API-provided severity field to find and color just "SEVERITY:"
within the message rather than the whole line. This avoids coloring the
full line (which is hard on the eyes) while still being more precise than
the old regex — no false matches when a severity word appears in the body.
@AdrianLC AdrianLC force-pushed the adrian/logs-severity-colorize branch from d2f4f86 to 388311c Compare April 10, 2026 11:12
@AdrianLC AdrianLC merged commit 7ac3cc3 into main Apr 13, 2026
2 checks passed
@AdrianLC AdrianLC deleted the adrian/logs-severity-colorize branch April 13, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants