Module: Kamal::Commands::App::Logging

Included in:
Kamal::Commands::App
Defined in:
lib/kamal/commands/app/logging.rb

Instance Method Summary collapse

Instance Method Details

#follow_logs(host:, timestamps: true, lines: nil, grep: nil, grep_options: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/kamal/commands/app/logging.rb', line 9

def follow_logs(host:, timestamps: true, lines: nil, grep: nil, grep_options: nil)
  run_over_ssh \
    pipe(
      current_running_container_id,
      "xargs docker logs#{" --timestamps" if timestamps}#{" --tail #{lines}" if lines} --follow 2>&1",
      (%(grep "#{grep}"#{" #{grep_options}" if grep_options}) if grep)
    ),
    host: host
end

#logs(version: nil, timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil) ⇒ Object



2
3
4
5
6
7
# File 'lib/kamal/commands/app/logging.rb', line 2

def logs(version: nil, timestamps: true, since: nil, lines: nil, grep: nil, grep_options: nil)
  pipe \
    version ? container_id_for_version(version) : current_running_container_id,
    "xargs docker logs#{" --timestamps" if timestamps}#{" --since #{since}" if since}#{" --tail #{lines}" if lines} 2>&1",
    ("grep '#{grep}'#{" #{grep_options}" if grep_options}" if grep)
end