Class: Lookout::Rack::Utils::Log
- Inherits:
-
Object
- Object
- Lookout::Rack::Utils::Log
- Includes:
- Log4r, Singleton
- Defined in:
- lib/lookout/rack/utils/log.rb
Overview
Logging. 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'
Defined Under Namespace
Classes: LookoutFormatter
Instance Attribute Summary collapse
-
#outputter ⇒ Object
readonly
Returns the value of attribute outputter.
Instance Method Summary collapse
-
#initialize ⇒ Log
constructor
A new instance of Log.
Constructor Details
#initialize ⇒ Log
Returns a new instance of Log.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/lookout/rack/utils/log.rb', line 91 def initialize logger_name = configatron.project_name.to_s.gsub(/\s*/, '_') if logger_name.nil? || logger_name.empty? logger_name = 'no_name_given' end @logger = Logger.new(logger_name) if configatron.logging.enabled index = Log4r::LNAMES.index(configatron.logging.level) # if logger.level is not in LNAMES an exception will be thrown @logger.level = index unless index.nil? else @logger.level = Log4r::OFF end @outputter = build_outputter(logger_name) @logger.trace = true @outputter.formatter = LookoutFormatter @logger.outputters = @outputter end |
Instance Attribute Details
#outputter ⇒ Object (readonly)
Returns the value of attribute outputter.
89 90 91 |
# File 'lib/lookout/rack/utils/log.rb', line 89 def outputter @outputter end |