Module: LogSwitch::ClassMethods
- Defined in:
- lib/log_switch.rb
Instance Method Summary collapse
- #before_log ⇒ Object
-
#before_log=(block) ⇒ Object
#log calls the block given to this method before it logs every time.
-
#default_log_level ⇒ Symbol
The current default log level.
- #default_log_level=(level) ⇒ Object
- #log_class_name ⇒ Object
-
#log_class_name=(value) ⇒ Object
Toggle prepending the class name of the #log caller to the log message.
-
#log_class_name? ⇒ Boolean
Tells whether logging of the class name with the log message is turned on.
- #logger ⇒ Object
- #logger=(new_logger) ⇒ Object
- #logging_enabled ⇒ Object
-
#logging_enabled=(value) ⇒ Object
Use to turn logging on or off.
-
#logging_enabled? ⇒ Boolean
Tells whether logging is turned on or not.
Instance Method Details
#before_log ⇒ Object
105 106 107 |
# File 'lib/log_switch.rb', line 105 def before_log @@before_block ||= Proc.new do; end end |
#before_log=(block) ⇒ Object
#log calls the block given to this method before it logs every time. This, thus, acts as a hook in the case where you want to make sure some code gets executed before you log a message. Useful for making sure a file exists before logging to it.
101 102 103 |
# File 'lib/log_switch.rb', line 101 def before_log=(block) @@before_block ||= block end |
#default_log_level ⇒ Symbol
Returns The current default log level. Starts off as :debug.
62 63 64 |
# File 'lib/log_switch.rb', line 62 def default_log_level @@default_log_level ||= :debug end |
#default_log_level=(level) ⇒ Object
67 68 69 |
# File 'lib/log_switch.rb', line 67 def default_log_level=(level) @@default_log_level = level end |
#log_class_name ⇒ Object
77 78 79 |
# File 'lib/log_switch.rb', line 77 def log_class_name @@log_class_name ||= true end |
#log_class_name=(value) ⇒ Object
Toggle prepending the class name of the #log caller to the log message.
82 83 84 |
# File 'lib/log_switch.rb', line 82 def log_class_name=(value) @@log_class_name = value end |
#log_class_name? ⇒ Boolean
Returns Tells whether logging of the class name with the log message is turned on.
73 74 75 |
# File 'lib/log_switch.rb', line 73 def log_class_name? log_class_name end |
#logger ⇒ Object
86 87 88 |
# File 'lib/log_switch.rb', line 86 def logger @@logger ||= LogSwitch.logger end |
#logger=(new_logger) ⇒ Object
90 91 92 |
# File 'lib/log_switch.rb', line 90 def logger=(new_logger) @@logger = new_logger end |
#logging_enabled ⇒ Object
43 44 45 |
# File 'lib/log_switch.rb', line 43 def logging_enabled @@logging_enabled ||= false end |
#logging_enabled=(value) ⇒ Object
Use to turn logging on or off.
57 58 59 |
# File 'lib/log_switch.rb', line 57 def logging_enabled=(value) @@logging_enabled = value end |
#logging_enabled? ⇒ Boolean
Tells whether logging is turned on or not.
50 51 52 |
# File 'lib/log_switch.rb', line 50 def logging_enabled? !!logging_enabled end |