Class: Rack::Audit
- Inherits:
-
Object
- Object
- Rack::Audit
- Defined in:
- lib/rack-audit/version.rb,
lib/rack-audit.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#queue ⇒ Object
readonly
Returns the value of attribute queue.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, name, url, options = {}) ⇒ Audit
constructor
A new instance of Audit.
Constructor Details
#initialize(app, name, url, options = {}) ⇒ Audit
Returns a new instance of Audit.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rack-audit.rb', line 15 def initialize(app, name, url, ={}) @app, @name, @url = app, name, url @queue = Queue.new @logger = [:logger] || Logger.new(STDOUT) @consumer = Thread.new do loop do body = self.queue.pop begin post(body) rescue => e self.logger.error("#{e.inspect}\n#{e.backtrace.join("\n\t")}") end end end end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
13 14 15 |
# File 'lib/rack-audit.rb', line 13 def host @host end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/rack-audit.rb', line 13 def name @name end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
13 14 15 |
# File 'lib/rack-audit.rb', line 13 def port @port end |
#queue ⇒ Object (readonly)
Returns the value of attribute queue.
13 14 15 |
# File 'lib/rack-audit.rb', line 13 def queue @queue end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
13 14 15 |
# File 'lib/rack-audit.rb', line 13 def url @url end |
Instance Method Details
#call(env) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rack-audit.rb', line 32 def call(env) id = UUIDTools::UUID.random_create.to_s log_request(id, env) response = @app.call(env) log_response(id, response) response end |