Configurable log levels

Allow ssh log_level to be set - this will help to debug connection
issues.
This commit is contained in:
Donal McBreen
2023-08-15 16:36:06 +01:00
parent 715cd94bbf
commit 1163c3de07
6 changed files with 33 additions and 7 deletions

View File

@@ -172,7 +172,7 @@ class Mrsk::Configuration
service_with_version: service_with_version,
env_args: env_args,
volume_args: volume_args,
ssh_options: ssh.options,
ssh_options: ssh.to_h,
sshkit: sshkit.to_h,
builder: builder.to_h,
accessories: raw_config.accessories,

View File

@@ -1,4 +1,6 @@
class Mrsk::Configuration::Ssh
LOGGER = ::Logger.new(STDERR)
def initialize(config:)
@config = config.raw_config.ssh || {}
end
@@ -16,9 +18,21 @@ class Mrsk::Configuration::Ssh
end
def options
{ user: user, proxy: proxy, auth_methods: [ "publickey" ], keepalive: true, keepalive_interval: 30 }.compact
{ user: user, proxy: proxy, auth_methods: [ "publickey" ], logger: logger, keepalive: true, keepalive_interval: 30 }.compact
end
def to_h
options.except(:logger).merge(log_level: log_level)
end
private
attr_accessor :config
def logger
LOGGER.tap { |logger| logger.level = log_level }
end
def log_level
config.fetch("log_level", :fatal)
end
end