lv

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT Imports: 6 Imported by: 0

README

lv

lv is a logviewer for Bunyan-based logs (like go-logger). It also supports pinojs logs.

Installation

Linux

You can grab the latest Debian/Ubuntu, RedHat package from the releases page and install it with the following commands:

If you use Homebrew, you can install lv with:

brew install gildas/tap/lv
macOS

You can get lv from Homebrew with:

brew install gildas/tap/lv
Binaries

You can download the latest version of lv from the releases page.

Usage

You can read logs from a file or from a pipe.

lv /path/to/logfile

or

tail -f /path/to/logfile | lv

By default, lv will display the log in a pager with colors, if the output is a terminal (you can turn off the pager with --no-pager). Any line that does cannot be unmarshaled in one of the supported format will be displayed as raw text.

It will also display the time in UTC. you can display the time in local time with the --local flag or use any timezone of your preference with --time xx where xx is the name of the timezone, a time difference from UTC.

lv --local /path/to/logfile
lv --time America/New_York /path/to/logfile
lv --time +02:00 /path/to/logfile
lv --time -3 /path/to/logfile

When the --o short flag is used, the time is displayed in a short format.

If the log entries contain a topic and a scope fields, lv will display them in color.

You can also use lv to filter logs by level:

lv --level=info /path/to/logfile

The level follows the go-logger format. For example:

  • --level=info will display logs of level info and above
  • --level=debug will display logs of level debug and above
  • --level 'INFO;DEBUG{topic};TRACE{:scope}' will display logs of level infoand debug for any entry with topic topic and trace for any entry with scope scope.

You can also filter logs with the --filter flag. The filter is similar to a JSONPath expression. For example:

lv --filter '.field == "value"' /path/to/logfile
lv --filter '.field1 == .field2' /path/to/logfile
lv --filter '.field =~ /regexp/' /path/to/logfile
lv --filter '.field1 == true && .field2 == 12' /path/to/logfile
Flags

Here is a list of the flags you can use with lv:

      --color              Colorize output always, even if the output stream is not a TTY. (default true)
  -c, --condition string   Run each log message through the filter.
      --debug              forces lv's logging at DEBUG level
  -f, --filter string      Run each log message through the filter.
  -h, --help               help for lv
      --level string       Only shows log entries with a level at or above the given value.
  -L, --local              Display time field in local time, rather than UTC.
      --log string         where lv's logs are writen if given (by default, no log is generated)
      --no-color           Do not colorize output. By default, the output is colorized if stdout is a TTY
      --no-pager           Do not pipe output into a pager. By default, the output is piped throug less 
                           (or $PAGER if set), if stdout is a TTY (default true)
  -o, --output string      output mode/format. One of long, json, short, html, serve, server (default "long")
      --time string        Display time field in the given timezone.
  -v, --verbose            runs verbosely if set
      --version            version for lv
Completion

lv supports shell completion for bash, fish, PowerShell, and zsh.

Bash

To enable completion, run the following command:

source <(lv --completion bash)

You can also add this line to your ~/.bashrc file to enable completion for every new shell.

lv --completion bash > ~/.bashrc
Fish

To enable completion, run the following command:

lv --completion fish | source

You can also add this line to your ~/.config/fish/config.fish file to enable completion for every new shell.

lv --completion fish > ~/.config/fish/completions/lv.fish
Powershell

To enable completion, run the following command:

lv --completion powershell | Out-String | Invoke-Expression

You can also add the output of the above command to your $PROFILE file to enable completion for every new shell.

zsh

To enable completion, run the following command:

source <(lv --completion zsh)

You can also add this line to your functions folder to enable completion for every new shell.

lv --completion zsh > "~/${fpath[1]}/_lv"

On macOS, you can add the completion to the brew functions:

lv --completion zsh > "$(brew --prefix)/share/zsh/site-functions/_lv"

Caveats

Not all the output formats are implemented yet.

Troubleshooting

lv uses go-logger to write its own logs. You can enable the logs with the --log flag. By default lv does not log anything.

TODO

  • Add support to read logs from aws, gcp and azure services.
  • Add support for k8s logs.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL