2 releases
new 0.1.1 | Mar 9, 2025 |
---|---|
0.1.0 | Mar 9, 2025 |
#703 in Command line utilities
10KB
93 lines
logt
Measuring the execution time of a longer running command is perfectly solved by the builtin time
that most shells provide. But in case you wanted to measure the individual steps a command takes, you might want to log the time of each outputted line. That's what logt is for.
logt executes a wrapped CLI command and annotates each output line with a timestamp like this:
Original command |
Wrapped command |
|
|
Installation
Execute cargo install logt
.
Synopsis
logt [FLAGS] [--] PROGRAM [ARGS]
Flag | Meaning |
---|---|
-r | Instead of the absolute time, show the duration since the start of the program. |
-s | For each line, show if it was emitted on stderr or stdout. |
-h | Show a more detailed help. |
The --
flag can be used to mark the end of logt flags. This would be useful in the unfortunate case that your program path or name starts with a hyphen, to distinguish it from a CLI option.
PROGRAM
can be a path (absolute/relative) to an executable or just a file name, if the executable is installed in one of the directories in the PATH
variable.
Example
$ logt -rs ./test.sh
[stdout +0.000873863s] Message 1
[stderr +0.000909503s] Message 2
[stdout +0.000918523s] Message 3
[stderr +0.000922283s] Message 4
Shortcomings
- Since
logt
is not a shell builtin, it can not directly execute bracket commands.time (a && b)
would therefore very roughly translate to something likelogt sh -c 'a && b'
.
Dependencies
~2–2.8MB
~49K SLoC