LogLayer, the modern logging library for Javascript / Typescript that supports shipping logs to loggers like Pino / Winston and SaaS providers like DataDog, now has a powerful pretty printing feature offered by the Pretty Terminal Transport:
- 🔍 Interactive Selection Mode - Browse and inspect logs in a full-screen interactive view
- 📝 Detailed Log Inspection - Examine individual log entries with formatted data and context
- 🔎 Search/Filter Functionality - Find specific logs with powerful filtering capabilities
- 💅 JSON Pretty Printing - Beautifully formatted structured data with syntax highlighting
- 🎭 Configurable Themes - Choose from pre-built themes or customize your own colors
Try it out
npm install loglayer @loglayer/transport-pretty-terminal serialize-error
import { LogLayer } from 'loglayer';
import { getPrettyTerminal } from '@loglayer/transport-pretty-terminal';
import { serializeError } from "serialize-error";
// Create LogLayer instance with the transport
const log = new LogLayer({
errorSerializer: serializeError,
transport: [
getPrettyTerminal()
],
});
// Start logging!
log.withMetadata({ foo: 'bar' }).info('Hello from Pretty Terminal!');
Simple View
You start out in the simple view, where your logs will print out. You can pause the log stream with "P".
Selection / search view
Pressing up or down in the simple view will switch to the selection / search view, where you can search through your logs:
Start typing to filter out logs:
Detailed view
This is useful for very nested JSON data or arrays. Selecting a log entry from the selection view will bring up the detailed view:
You can scroll through the data, and use keyboard commands like "C" to expand out arrays to see the underlying data in them.
JSON view
Pressing "J" in the detailed view will print out the raw JSON, giving you an opportunity to properly copy the JSON data for use elsewhere:
For more information
For using LogLayer in general, visit the site to get started.
If you want to learn more about the different themes (including creating your own), and keyboard shortcuts for the pretty print, check out the Pretty Terminal Transport documentation.
Top comments (0)