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