Class: Kamal::Configuration::Logging

Inherits:
Object
  • Object
show all
Includes:
Validation
Defined in:
lib/kamal/configuration/logging.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Validation

#validate!, #validation_yml

Constructor Details

#initialize(logging_config:, context: "logging") ⇒ Logging

Returns a new instance of Logging.



8
9
10
11
# File 'lib/kamal/configuration/logging.rb', line 8

def initialize(logging_config:, context: "logging")
  @logging_config = logging_config || {}
  validate! @logging_config, context: context
end

Instance Attribute Details

#logging_configObject (readonly)

Returns the value of attribute logging_config.



6
7
8
# File 'lib/kamal/configuration/logging.rb', line 6

def logging_config
  @logging_config
end

Instance Method Details

#argsObject



25
26
27
28
29
30
31
32
# File 'lib/kamal/configuration/logging.rb', line 25

def args
  if driver.present? || options.present?
    optionize({ "log-driver" => driver }.compact) +
      argumentize("--log-opt", options)
  else
    argumentize("--log-opt", { "max-size" => "10m" })
  end
end

#driverObject



13
14
15
# File 'lib/kamal/configuration/logging.rb', line 13

def driver
  logging_config["driver"]
end

#merge(other) ⇒ Object



21
22
23
# File 'lib/kamal/configuration/logging.rb', line 21

def merge(other)
  self.class.new logging_config: logging_config.deep_merge(other.logging_config)
end

#optionsObject



17
18
19
# File 'lib/kamal/configuration/logging.rb', line 17

def options
  logging_config.fetch("options", {})
end