Module: TrainPlugins::Juniper::Logging
- Included in:
- Connection
- Defined in:
- lib/train-juniper/helpers/logging.rb
Overview
Provides consistent logging patterns across the plugin
Instance Method Summary collapse
-
#log_bastion_connection(bastion_host) ⇒ Object
Log bastion connection attempt.
-
#log_command(cmd) ⇒ Object
Log a command execution attempt.
-
#log_connection_attempt(target, port = nil) ⇒ Object
Log a connection attempt.
-
#log_connection_success(target) ⇒ Object
Log successful connection.
-
#log_error(error, context = nil) ⇒ Object
Log an error with consistent formatting.
-
#log_mock_mode ⇒ Object
Log mock mode activation.
-
#log_platform_detection(platform_name, version) ⇒ Object
Log platform detection results.
-
#log_ssh_options(options) ⇒ Object
Log SSH session details (redacting sensitive info).
Instance Method Details
#log_bastion_connection(bastion_host) ⇒ Object
Log bastion connection attempt
67 68 69 |
# File 'lib/train-juniper/helpers/logging.rb', line 67 def log_bastion_connection(bastion_host) @logger.debug("Connecting through bastion host: #{bastion_host}") end |
#log_command(cmd) ⇒ Object
Log a command execution attempt
9 10 11 |
# File 'lib/train-juniper/helpers/logging.rb', line 9 def log_command(cmd) @logger.debug("Executing command: #{cmd}") end |
#log_connection_attempt(target, port = nil) ⇒ Object
Log a connection attempt
16 17 18 19 20 21 22 |
# File 'lib/train-juniper/helpers/logging.rb', line 16 def log_connection_attempt(target, port = nil) if port @logger.debug("Attempting connection to #{target}:#{port}") else @logger.debug("Attempting connection to #{target}") end end |
#log_connection_success(target) ⇒ Object
Log successful connection
43 44 45 |
# File 'lib/train-juniper/helpers/logging.rb', line 43 def log_connection_success(target) @logger.info("Successfully connected to #{target}") end |
#log_error(error, context = nil) ⇒ Object
Log an error with consistent formatting
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/train-juniper/helpers/logging.rb', line 27 def log_error(error, context = nil) = if error.is_a?(Exception) "#{error.class}: #{error.}" else error.to_s end if context @logger.error("#{context}: #{}") else @logger.error() end end |
#log_mock_mode ⇒ Object
Log mock mode activation
72 73 74 |
# File 'lib/train-juniper/helpers/logging.rb', line 72 def log_mock_mode @logger.info('Running in mock mode - no real device connection') end |
#log_platform_detection(platform_name, version) ⇒ Object
Log platform detection results
61 62 63 |
# File 'lib/train-juniper/helpers/logging.rb', line 61 def log_platform_detection(platform_name, version) @logger.info("Platform detected: #{platform_name} #{version}") end |
#log_ssh_options(options) ⇒ Object
Log SSH session details (redacting sensitive info)
49 50 51 52 53 54 55 56 |
# File 'lib/train-juniper/helpers/logging.rb', line 49 def () = .dup [:password] = '[REDACTED]' if [:password] [:passphrase] = '[REDACTED]' if [:passphrase] [:keys] = [:keys]&.map { |k| File.basename(k) } if [:keys] @logger.debug("SSH options: #{.inspect}") end |