Skip to content
/ poglog Public

A fast, colorful PostgreSQL JSON log highlighter and SQL formatter for your terminal, written in Rust.

License

Notifications You must be signed in to change notification settings

amureki/poglog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

poglog

A fast, colorful PostgreSQL JSON log highlighter and SQL formatter for your terminal, written in Rust.

Features

  • Parses and highlights logs in PostgreSQL's jsonlog format
  • Formats (pretty-prints) SQL queries for readability and highlights them with syntax coloring
  • Colorizes timestamps, log levels, durations, and other key fields
  • Indents and colorizes important keywords in non-SQL log messages

PostgreSQL jsonlog support

poglog is designed for PostgreSQL's jsonlog format, providing robust and structured log parsing.

To enable jsonlog in your PostgreSQL configuration, add or modify the following lines in your postgresql.conf:

log_destination = 'jsonlog'
logging_collector = on

Restart PostgreSQL after making these changes. Your logs will now be written in JSON format, which poglog will automatically detect and process.

Installation

Install poglog from crates.io using Cargo:

cargo install poglog

This will download, build, and install the poglog binary to your Cargo bin directory (usually ~/.cargo/bin).

Usage

Pipe your Postgres JSON logs into poglog:

tail -f /path/to/log.json | poglog

Or process a file:

cat /path/to/log.json | poglog

Example

Input (jsonlog):

{"timestamp":"2025-06-11 18:15:14.380 CEST","pid":47538,"user":"pogstar","dbname":"caps","error_severity":"LOG","message":"duration: 1.234 ms  statement: SELECT * FROM logs WHERE level = 'ERROR' AND service = 'auth'"}
{"timestamp":"2025-06-11 18:20:11.064 CEST","pid":47526,"error_severity":"LOG","message":"checkpoint starting: time"}

Output (colorized, formatted):

2025-06-11 18:15:14.380 CEST LOG pid=47538 user=pogstar db=caps duration: 1.234 ms
    SELECT *
    FROM logs
    WHERE level = 'ERROR'
      AND service = 'auth'
2025-06-11 18:20:11.064 CEST LOG pid=47526
    checkpoint starting: time

About

A fast, colorful PostgreSQL JSON log highlighter and SQL formatter for your terminal, written in Rust.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages