Add grep's context option to show lines before and after a match
This commit is contained in:
@@ -36,17 +36,17 @@ class Kamal::Commands::Accessory < Kamal::Commands::Base
|
||||
end
|
||||
|
||||
|
||||
def logs(since: nil, lines: nil, grep: nil)
|
||||
def logs(since: nil, lines: nil, grep: nil, context: nil)
|
||||
pipe \
|
||||
docker(:logs, service_name, (" --since #{since}" if since), (" --tail #{lines}" if lines), "--timestamps", "2>&1"),
|
||||
("grep '#{grep}'" if grep)
|
||||
("grep '#{grep}'#{" -C #{context}" if context}" if grep)
|
||||
end
|
||||
|
||||
def follow_logs(grep: nil)
|
||||
def follow_logs(grep: nil, context: nil)
|
||||
run_over_ssh \
|
||||
pipe \
|
||||
docker(:logs, service_name, "--timestamps", "--tail", "10", "--follow", "2>&1"),
|
||||
(%(grep "#{grep}") if grep)
|
||||
(%(grep "#{grep}"#{" -C #{context}" if context}) if grep)
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user