lv is a logviewer for Bunyan-based logs (like go-logger). It also supports pinojs logs.
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/lvYou can also install the application with snap:
sudo snap install bunyan-logviewer
sudo snap alias bunyan-logviewer lvYou can get lv from Homebrew with:
brew install gildas/tap/lvYou can install lv with chocolatey:
choco install bunyan-logviewerYou can also install lv with scoop:
scoop bucket add gildas https://github.com/gildas/scoop-bucket
scoop install lvYou can download the latest version of lv from the releases page.
You can read logs from a file or from a pipe.
lv /path/to/logfileor
tail -f /path/to/logfile | lvBy 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/logfileWhen 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/logfileThe level follows the go-logger format. For example:
--level=infowill display logs of levelinfoand above--level=debugwill display logs of leveldebugand above--level 'INFO;DEBUG{topic};TRACE{:scope}'will display logs of levelinfoanddebugfor any entry with topictopicandtracefor any entry with scopescope.
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/logfileHere 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.
-k, --key string Use the given key to decrypt obfuscated log entries.
-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 lvThe key must be 16, 24, or 32 bytes long.
lv uses the following environment variables:
LV_COLORto force colorization of the outputLV_LOCALto display the time in local timeLV_TIMEZONEto display the time in a specific timezoneLV_OBFUSCATIONKEYto specify the key used to decrypt obfuscated log entries
The command line flags have precedence over the environment variables.
You can also configure lv with a configuration file. The configuration file is a YAML file called config.yaml and should be stored in the subfolder logviewer of os.UserConfigDir.
Here is an example of a configuration file:
color: true
local: true
output: short
obfuscationKey: 1231213The environment variables and the command line flags have precedence over the configuration file.
lv supports shell completion for bash, fish, PowerShell, and zsh.
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 > ~/.bashrcTo enable completion, run the following command:
lv --completion fish | sourceYou 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.fishTo enable completion, run the following command:
lv --completion powershell | Out-String | Invoke-ExpressionYou can also add the output of the above command to your $PROFILE file to enable completion for every new shell.
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"Not all the output formats are implemented yet.
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. lv will read the go-logger environment variables with the prefix LV_ (For example LV_LOG_LEVEL).
- Add support to read logs from
aws,gcpandazureservices. - Add support for
k8slogs.