Class: Lookout::Rack::Utils::Log
- Inherits:
-
Object
- Object
- Lookout::Rack::Utils::Log
- Defined in:
- lib/lookout/rack/utils/log.rb
Overview
Logging. By default, logs to log/<project_name>.log with the format:
[Log Level]: [Timestamp (ISO-8601)]: [File:linenum]: [Log Message]
Use through the helper:
log.warn 'This is my log message'
Default logger may be replaced by calling
Log.set_instance(my_logger)
Constant Summary collapse
- @@instance =
nil
Class Method Summary collapse
-
.clear_instance ⇒ Object
Clear singleton instance, for use in testing ONLY.
-
.create_instance ⇒ Object
Initialize singleton instance to be an instance of
Lookout::Rack::Utils::LookoutLogger
, with the given options. -
.instance ⇒ Object
Access singleton instance, which must have been initialized with .create_instance or .set_instance.
-
.instance_set? ⇒ Boolean
Check if the instance has been set.
-
.set_instance(instance) ⇒ Object
Explicitly set singleton instance.
Class Method Details
.clear_instance ⇒ Object
Clear singleton instance, for use in testing ONLY
36 37 38 |
# File 'lib/lookout/rack/utils/log.rb', line 36 def self.clear_instance @@instance = nil end |
.create_instance ⇒ Object
Initialize singleton instance to be an instance of Lookout::Rack::Utils::LookoutLogger
, with the given options
23 24 25 26 |
# File 'lib/lookout/rack/utils/log.rb', line 23 def self.create_instance raise "Already initialized Log" if instance_set? @@instance = LookoutLogger.new end |
.instance ⇒ Object
Access singleton instance, which must have been initialized with .create_instance or .set_instance
47 48 49 50 |
# File 'lib/lookout/rack/utils/log.rb', line 47 def self.instance create_instance if @@instance.nil? @@instance end |
.instance_set? ⇒ Boolean
Check if the instance has been set
41 42 43 |
# File 'lib/lookout/rack/utils/log.rb', line 41 def self.instance_set? defined?(@@instance) && !!@@instance end |
.set_instance(instance) ⇒ Object
Explicitly set singleton instance. The instance must implement the same base API as ::Logger
30 31 32 33 |
# File 'lib/lookout/rack/utils/log.rb', line 30 def self.set_instance(instance) raise "Already initialized Log" if instance_set? @@instance = instance end |