#log #output #command-line-tool #terminal #utility #message #last

app watchlog

A command-line utility to help you see how a log is moving

124 stable releases

new 1.238.0 Apr 17, 2024
1.234.0 Mar 28, 2024
1.222.0 Dec 8, 2023
1.216.0 Sep 3, 2023
0.0.0 Mar 25, 2021

#64 in Debugging

Download history 4/week @ 2024-01-18 5/week @ 2024-01-25 16/week @ 2024-02-08 15/week @ 2024-02-15 63/week @ 2024-02-22 61/week @ 2024-02-29 156/week @ 2024-03-07 131/week @ 2024-03-14 23/week @ 2024-03-21 170/week @ 2024-03-28 10/week @ 2024-04-04

337 downloads per month

Apache-2.0 and LGPL-2.0-or-later

180KB
201 lines

watchlog

Do you ever have a terminal watching logs or recompiling on save and you aren't sure if the most recent messages are from the change you just made, or 10 minutes ago? watchlog will help you but adding a message at the bottom of your terminal that haven't produced output recently. After a short period of no output watchlog will start displaying the time since last output below the command.

HTTP/1.1 GET /api/books/1 500
HTTP/1.1 GET /api/books/2 500
HTTP/1.1 GET /api/books/1 500
HTTP/1.1 GET /api/books/1 200
Last output 48s ago.

When the command produces more output it will look like normal if it hasn't been too long, however if it has been a while watchlog will inject a timestamp so that the logs are grouped by when they occurred when you scroll up.

If you still don't get it I have a longer explanation of how I use watchlog on my blog.

Demo

A demo at 6x speed.

demo of watchlog

Usage

Simply put | wl after your command.

$ python -m http.server | wl

Configuration

watchlog can be configured with watchlog/config.scfg. This file will be read from all of the appropriate places for your platform. For example on a Linux system it will be looked for in ~/.config/watchlog and /etc/xdg/watchlog (or whatever you have configured in $XDG_CONFIG_DIRS). If multiple files are found they will be merged according to precedence. If a value is not set in any config file a builtin default will be used.

The following options are supported, the first example for each option shows the default value.

Options

delay (Duration)

Enable watchlog when there is no output for this long.

delay: 3s

permanent-delay (Option<Duration>)

Insert a permanent timestamp into the output after a delay of at least this long.

Note that a timestamp is never inserted after pauses which occur mid-line.

permanent-delay: 10s
permanent-delay: never

Types

Duration

Durations can be specified in a simple form with units.

delay: 10s
permanent-delay: 1h 2m 30s

Option<Duration>

Optional durations can be set to never for an infinite duration or a Duration value.

permanent-delay: never

Installation

Cargo

$ cargo install watchlog

Nix

watchlog is available in nixpkgs

Or you can build from source:

$ nix-env -i -f https://gitlab.com/kevincox/watchlog/-/archive/v1/watchlog-v1.tar.bz2 -A watchlog

Questions, Comments or Feedback

I am happy to answer any questions, discuss features, bugs or possible contributions. Just open an issue (even if you just want to say hello).

Dependencies

~4–14MB
~141K SLoC