Tool for working with streaming logs from Heroku.
Should work with logs from any web framework, but we use it with our Rails API.
Running the program will start tailing the logs in the background and open a prompt:
> type command here
The supported commands are:
exit
: Stop the program.f
,fail
: Print lines that matchCompleted [^2]
. Used to find failed requests. Subsequent runs of the command will ignore lines previously printed. So if you see no output, then there are no new failed requests.save
,s
,write
,w
: Write the logs to a file namedlogs
.- Any other input: Search the logs for the input (ignoring case) and print matching lines.
For the time being you have to compile it yourself, but that should be very straight forward.
- Install Rust
- Download the source:
git clone https://github.com/tonsser/tsrlog-rs
- Compile:
cargo build --release
- Make a configuration file. See chapter below 👇
You can now run it with ./target/release/tsrlog-rs ARG
.
The code expects a file named tsrlog_config.yaml
in the current directory. The file should look like this:
production: some-heroku-app-production
staging: some-heroku-app-staging
Running the command ./target/release/tsrlog-rs production
will look for the key production
in the configuration file, and tail logs from the Heroku app with the corresponding name.
If you feel like it you can also make some shorthands:
production: some-heroku-app-production
p: some-heroku-app-production
staging: some-heroku-app-staging
s: some-heroku-app-staging
Empty lines in the configuration file are ignored.
The code doesn't support tracking history and using the arrow keys to move up and down. For that we recommend you use rlwrap
. It can be installed with brew install rlwrap
.
I recommend adding a shell alias like:
alias tsrlog='rlwrap PATH_TO_BINARY'