format-json-log

Crates.ioformat-json-log
lib.rsformat-json-log
version0.1.0
sourcesrc
created_at2023-07-19 22:39:32.370107
updated_at2023-07-19 22:39:32.370107
descriptionA command line tool to format format json structured log message lines from stdin into ANSI coloured stdout.
homepage
repositoryhttps://github.com/kellpossible/format-json-log
max_upload_size
id920766
size27,568
Luke Frisken (kellpossible)

documentation

README

format-json-log

A command line tool to format format json structured log message lines from stdin into ANSI coloured stdout.

Installation

Install using cargo install format-json-log.

Usage

Usage: format-json-log [OPTIONS]

Options:
  -m, --message-pointer <MESSAGE_POINTER>
          JSON pointer to the message string

          [default: /fields/message]

  -t, --timestamp-pointer <TIMESTAMP_POINTER>
          JSON pointer to the timestamp string

          [default: /timestamp]

  -l, --level-pointer <LEVEL_POINTER>
          JSON pointer to the log level string

          [default: /level]

  -f, --format <FORMAT>
          What output format to use

          [default: line]

          Possible values:
          - line: Similar to what `tracing_subscriber` outputs
          - json: Coloured json, with a level heading per line

  -h, --help
          Print help (see a summary with '-h')

k9s Plugin

This tool was originally designed to be used to format json log messages as a plugin in k9s.

In ~/.config/k9s/plugin.yml put the following:

plugin:
  pinologs:
    shortCut: Shift-L
    description: "attach (pretty)"
    scopes:
      - po
    command: bash
    args:
      - "-i"
      - "-c"
      - "kubectl logs -f $NAME -n $NAMESPACE --context $CONTEXT | format-json-log"
Commit count: 6

cargo fmt