Class: Insight::Logger
- Inherits:
-
Object
- Object
- Insight::Logger
- Defined in:
- lib/insight/logger.rb
Constant Summary
- DEBUG =
0- INFO =
1- WARN =
2- ERROR =
3- FATAL =
4- UNKNOWN =
5
Instance Attribute Summary (collapse)
-
- (Object) level
Returns the value of attribute level.
Instance Method Summary (collapse)
- - (Object) debug
- - (Object) error
- - (Object) fatal
- - (Object) info
-
- (Logger) initialize(level, path)
constructor
A new instance of Logger.
- - (Object) log(severity, message)
- - (Object) logfile
- - (Object) unknown
- - (Object) warn
Constructor Details
- (Logger) initialize(level, path)
A new instance of Logger
3 4 5 6 7 |
# File 'lib/insight/logger.rb', line 3 def initialize(level, path) @level = level @log_path = path @logfile = nil end |
Instance Attribute Details
- (Object) level
Returns the value of attribute level
9 10 11 |
# File 'lib/insight/logger.rb', line 9 def level @level end |
Instance Method Details
- (Object) debug
35 |
# File 'lib/insight/logger.rb', line 35 def debug; log(DEBUG, yield) end |
- (Object) error
38 |
# File 'lib/insight/logger.rb', line 38 def error; log(ERROR, yield) end |
- (Object) fatal
39 |
# File 'lib/insight/logger.rb', line 39 def fatal; log(FATAL, yield) end |
- (Object) info
36 |
# File 'lib/insight/logger.rb', line 36 def info; log(INFO, yield) end |
- (Object) log(severity, message)
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/insight/logger.rb', line 18 def log(severity, ) = .inspect unless String === return unless severity >= @level if defined? Rails and Rails.respond_to?(:logger) and not Rails.logger.nil? Rails.logger.add(severity, "[Insight]: " + ) end logfile.puts() end |
- (Object) logfile
29 30 31 32 33 |
# File 'lib/insight/logger.rb', line 29 def logfile @logfile ||= File::open(@log_path, "a+") rescue $stderr end |
- (Object) unknown
40 |
# File 'lib/insight/logger.rb', line 40 def unknown; log(UNKNOWN, yield) end |
- (Object) warn
37 |
# File 'lib/insight/logger.rb', line 37 def warn; log(WARN, yield) end |