Class: Traitify::Middleware::Formatter
- Inherits:
-
Object
- Object
- Traitify::Middleware::Formatter
- Extended by:
- Forwardable
- Defined in:
- lib/traitify/middleware/formatter.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(logger:, options:) ⇒ Formatter
constructor
A new instance of Formatter.
- #request(env) ⇒ Object
- #response(env) ⇒ Object
Constructor Details
#initialize(logger:, options:) ⇒ Formatter
Returns a new instance of Formatter.
8 9 10 11 |
# File 'lib/traitify/middleware/formatter.rb', line 8 def initialize(logger:, options:) @logger = logger @options = {log_level: :info, prefix: "[traitify-ruby]"}.merge() end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/traitify/middleware/formatter.rb', line 6 def logger @logger end |
#options ⇒ Object
Returns the value of attribute options.
6 7 8 |
# File 'lib/traitify/middleware/formatter.rb', line 6 def @options end |
Instance Method Details
#request(env) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/traitify/middleware/formatter.rb', line 15 def request(env) log(env[:method].upcase, env.url.to_s) log("AUTH", env.request_headers["Authorization"], level: :debug) log("BODY", env.body) log("PARAMS", query_params(env)) end |
#response(env) ⇒ Object
22 23 24 |
# File 'lib/traitify/middleware/formatter.rb', line 22 def response(env) log("STATUS", env.status) end |