Module: Logging::Rails::Mixin
- Defined in:
- lib/logging/rails/mixin.rb
Overview
Include this module into your ApplicationController to provide per-controller log level configurability. You can also include this module into your models or anywhere else you would like to control the log level.
Alternatively, you can use the ‘include Logging.globally` trick to add a `logger` method to every Object in the ruby interpreter. See github.com/TwP/logging/blob/master/lib/logging.rb#L214 for more details.
Class Method Summary collapse
-
.extended(other) ⇒ Object
This method is called when the modules is extended into another class or module.
-
.included(other) ⇒ Object
This method is called when the module is included into a class.
Instance Method Summary collapse
-
#logger ⇒ Object
Returns the logger instance.
Class Method Details
.extended(other) ⇒ Object
This method is called when the modules is extended into another class or module. It will remove any existing ‘logger` method and insert its own version.
27 28 29 30 |
# File 'lib/logging/rails/mixin.rb', line 27 def self.extended( other ) eigenclass = class << other; self; end eigenclass.__send__(:remove_method, :logger) if eigenclass.instance_methods.include? :logger end |
.included(other) ⇒ Object
This method is called when the module is included into a class. It will extend the including class so it also has a class-level ‘logger` method.
18 19 20 21 |
# File 'lib/logging/rails/mixin.rb', line 18 def self.included( other ) other.__send__(:remove_method, :logger) if other.instance_methods.include? :logger other.extend self end |
Instance Method Details
#logger ⇒ Object
Returns the logger instance.
34 35 36 |
# File 'lib/logging/rails/mixin.rb', line 34 def logger @logger ||= ::Logging::Logger[self] end |