Module: Legion::Logging::Helper
- Included in:
- Crypt, Crypt::Attestation, Crypt::CertRotation, Crypt::Cipher, Crypt::ClusterSecret, Crypt::Ed25519, Crypt::Erasure, Crypt::JWT, Crypt::JwksClient, Crypt::KerberosAuth, Crypt::LdapAuth, Crypt::LeaseManager, Crypt::Mtls, Crypt::PartitionKeys, Crypt::Settings, Crypt::Spiffe, Crypt::Spiffe::IdentityHelpers, Crypt::Spiffe::SvidRotation, Crypt::Spiffe::WorkloadApiClient, Crypt::TLS, Crypt::TokenRenewer, Crypt::Vault, Crypt::VaultCluster, Crypt::VaultEntity, Crypt::VaultJwtAuth, Crypt::VaultKerberosAuth
- Defined in:
- lib/legion/logging/helper.rb
Constant Summary collapse
- CompatLogger =
Class.new do %i[debug info warn error fatal unknown].each do |level| define_method(level) do | = nil, &block| payload = block ? block.call : return if payload.nil? if logging_supports?(level) Legion::Logging.public_send(level, payload) elsif %i[error fatal warn].include?(level) ::Kernel.warn(payload) else $stdout.puts(payload) end end end private def logging_supports?(level) return false unless Legion.const_defined?('Logging') Legion::Logging.respond_to?(level) rescue StandardError false end end
Instance Method Summary collapse
-
#handle_exception(exception, task_id: nil, level: :error, handled: true, **opts) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument,Style/ArgumentsForwarding.
- #log ⇒ Object
Instance Method Details
#handle_exception(exception, task_id: nil, level: :error, handled: true, **opts) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument,Style/ArgumentsForwarding
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/legion/logging/helper.rb', line 51 def handle_exception(exception, task_id: nil, level: :error, handled: true, **opts) # rubocop:disable Lint/UnusedMethodArgument,Style/ArgumentsForwarding = (exception, level: level, **opts) # rubocop:disable Style/ArgumentsForwarding if logging_supports?(:log_exception) Legion::Logging.log_exception(exception, level: level, lex: 'crypt', component_type: :helper) return end if logging_supports?(level) Legion::Logging.public_send(level, ) return end if logging_supports?(:error) Legion::Logging.error() return end if logging_supports?(:warn) Legion::Logging.warn() return end ::Kernel.warn() end |
#log ⇒ Object
47 48 49 |
# File 'lib/legion/logging/helper.rb', line 47 def log @log ||= CompatLogger.new end |