Execute `gdk run` in background and attach the log stream from different shell
Is it possible to execute gdk run
in background and attach the log stream from different shell?
For example,
Terminal 1
$ gdk run -d # Background launch
$
Terminal 2
$ gdk log -f | grep "What I want to observe" # Log tail with grep
22:20:24 gitlab-workhorse.1 | 192.168.10.5:3000 192.168.10.5:53484 - - [2017-02-23 22:20:24.823152105 +0900 JST] "POST /ci/api/v1/builds/register.json HTTP/1.1" 204 0 "" "gitlab-ci-multi-runner 1.10.4 (1-10-stable; go1.7.5; darwin/amd64)" 0.097107
22:20:27 gitlab-workhorse.1 | 192.168.10.5:3000 192.168.10.5:53484 - - [2017-02-23 22:20:27.826450674 +0900 JST] "POST /ci/api/v1/builds/register.json HTTP/1.1" 204 0 "" "gitlab-ci-multi-runner 1.10.4 (1-10-stable; go1.7.5; darwin/amd64)" 0.106090
...
Because sometimes i put a log code like puts "TAG: #{blah}"
and observe the only TAG value for debugging.
I can search by terminal find function(i.e. Cmd+F
), but sometimes it's hard to detect the relevant log because log stream is fast.
I also can do like gdk run | grep "What I want to observe"
but this is annoying when the grep target is frequently changed.
This is my current work around, but heavy load.
Terminal 1
rm gdk.log && gdk run >> gdk.log
Terminal 2
tail -f gdk.log | awk '/gitlab-workhorse/ {print "\033[32m" $0 "\033[39m"} \
/rails-background-jobs/ {print "\033[33m" $0 "\033[39m"} \
!/[gitlab-workhorse|rails-background-jobs]/ {print "\033[31m" $0 "\033[39m"}' | grep "What I want to observe"