Module: Eco::Language::AuxiliarLogger
- Included in:
- API::Common::Loaders::Base, API::Common::People::DefaultParsers::Helpers::ExpectedHeaders, API::Common::People::PersonEntry, API::Common::People::PersonEntryAttributeMapper, API::Common::Session::BaseSession, API::Common::Session::FileManager, API::Common::Session::Mailer, API::Common::Session::Mailer::ProviderBase, API::Common::Session::S3Uploader, API::Common::Session::SFTP, API::Session::Batch::Errors, API::Session::Config::BaseConfig, API::UseCases::BaseIO, API::UseCases::GraphQL::Helpers::Base::CaseEnv, API::UseCases::GraphQL::Helpers::Base::ErrorHandling, API::UseCases::GraphQL::Helpers::Location::Command, API::UseCases::OozeSamples::HelpersMigration::Copying, CSV::Split, CSV::Stream, Data::Files::Encoding, Data::Files::InstanceMethods, Data::Hashes::ArrayDiff, Data::Locations::Convert, Data::Locations::NodeBase::TagValidations, Data::Locations::NodeBase::Treeify, Data::Locations::NodeLevel::Cleaner
- Defined in:
- lib/eco/language/auxiliar_logger.rb
Overview
Some modules/classes use logger, but they may not be connected to session. This prevents errors with this.
Instance Attribute Summary collapse
-
#logger ⇒ Object
Provides either an available logger or a basic one.
Instance Method Summary collapse
-
#log(*levels, &block) ⇒ NilClass
Shortcut to logger.
Instance Attribute Details
#logger ⇒ Object
Provides either an available logger or a basic one
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/eco/language/auxiliar_logger.rb', line 9 def logger if instance_variable_defined?(:@session) && !@session.nil? @session.logger elsif respond_to?(:session) session.logger elsif Object.const_defined?(:ASSETS) ASSETS.session.logger elsif defined?(super) super else @logger ||= Eco::Language::BasicLogger.new end end |
Instance Method Details
#log(*levels, &block) ⇒ NilClass
TODO:
allow for more channels (atm it's just :general )
Note:
when :general
is included, it ensures at least
:info
level is also logged.
Shortcut to logger.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/eco/language/auxiliar_logger.rb', line 28 def log(*levels, &block) return unless logger levels = levels.compact.uniq.map(&:to_sym) levels.unshift(:info) if levels.include?(:general) && levels.length == 1 levels.each do |level| next unless logger.respond_to?(:level) logger.send(level, &block) end nil end |