Class: Rack::Handler::JettyLogAdapter
- Inherits:
-
Object
- Object
- Rack::Handler::JettyLogAdapter
- Defined in:
- lib/rack/handler/jetty/log_adapter.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #debug(msg, *args) ⇒ Object
- #error(msg, *args) ⇒ Object
- #fatal(msg, *args) ⇒ Object
- #get_logger(name) ⇒ Object
- #info(msg, *args) ⇒ Object
-
#initialize(l = nil, prefix = '') ⇒ JettyLogAdapter
constructor
A new instance of JettyLogAdapter.
- #is_debug_enabled ⇒ Object
- #set_debug_enabled ⇒ Object
- #sub(msg, *args) ⇒ Object
- #warn(msg, *args) ⇒ Object
Constructor Details
#initialize(l = nil, prefix = '') ⇒ JettyLogAdapter
Returns a new instance of JettyLogAdapter.
11 12 13 14 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 11 def initialize(l=nil, prefix='') @logger = l || ::Logger.new(STDOUT) @prefix = prefix end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 9 def logger @logger end |
Instance Method Details
#debug(msg, *args) ⇒ Object
32 33 34 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 32 def debug(msg, *args) logger.debug(@prefix + sub(msg, args)) end |
#error(msg, *args) ⇒ Object
36 37 38 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 36 def error(msg, *args) logger.error(@prefix + sub(msg, args)) end |
#fatal(msg, *args) ⇒ Object
40 41 42 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 40 def fatal(msg, *args) logger.fatal(@prefix + sub(msg, args)) end |
#get_logger(name) ⇒ Object
44 45 46 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 44 def get_logger(name) self end |
#info(msg, *args) ⇒ Object
28 29 30 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 28 def info(msg, *args) logger.info(@prefix + sub(msg, args)) end |
#is_debug_enabled ⇒ Object
16 17 18 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 16 def is_debug_enabled logger.debug? end |
#set_debug_enabled ⇒ Object
20 21 22 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 20 def set_debug_enabled logger.warn("can't change logging status") end |
#sub(msg, *args) ⇒ Object
48 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 48 def sub(msg, *args); msg.gsub("{}") { args.shift }; end |
#warn(msg, *args) ⇒ Object
24 25 26 |
# File 'lib/rack/handler/jetty/log_adapter.rb', line 24 def warn(msg, *args) logger.warn(@prefix + sub(msg, args)) end |