Class: QuickLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/rails2ext/active_support/quick_logger.rb

Overview

quick and dirty logger: just inherit from here,  set the filename attribute then you’re ready to go

Direct Known Subclasses

Quick::Logger

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.filenameObject

Returns the value of attribute filename.



7
8
9
# File 'lib/rails2ext/active_support/quick_logger.rb', line 7

def filename
  @filename
end

Class Method Details

.filename_pathObject



9
10
11
12
13
14
15
# File 'lib/rails2ext/active_support/quick_logger.rb', line 9

def filename_path
  if defined?(Rails)
    File.join Rails.root, 'log', [@filename, Rails.env, 'log'].join('.')
  else
    [@filename, 'log'].join('.')
  end
end

.method_missing(log_level, message) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/rails2ext/active_support/quick_logger.rb', line 17

def method_missing(log_level, message)
  @logger ||= ::Logger.new(filename_path)
  if ::Logger::SEV_LABEL.include?(log_level.to_s.upcase)
    @logger.send log_level, "[#{Time.now}] #{message}"
  else
    super
  end
end