Class: Parse::Middleware::Logging
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Parse::Middleware::Logging
- Defined in:
- lib/parse/client/logging.rb
Overview
Faraday middleware that logs Parse API requests and responses.
This middleware provides detailed logging of HTTP requests and responses with configurable log levels and optional body truncation for large payloads.
Log levels:
- :info - Logs request method, URL, status, and timing
- :debug - Also logs headers and truncated body content
- :warn - Only logs errors and warnings
Constant Summary collapse
- MAX_BODY_LENGTH =
Maximum length of body content to log before truncation
500
Class Attribute Summary collapse
-
.enabled ⇒ Boolean
Whether logging is enabled.
-
.log_level ⇒ Symbol
The log level (:info, :debug, :warn).
-
.logger ⇒ Logger
The logger instance to use.
-
.max_body_length ⇒ Integer
Maximum body length to log (defaults to MAX_BODY_LENGTH).
Class Method Summary collapse
-
.current_log_level ⇒ Symbol
Get the current log level (defaults to :info).
-
.current_logger ⇒ Logger
Get the configured logger or default.
-
.current_max_body_length ⇒ Integer
Get the max body length (defaults to MAX_BODY_LENGTH).
-
.default_logger ⇒ Logger
Default logger instance.
Class Attribute Details
.enabled ⇒ Boolean
Returns Whether logging is enabled.
37 38 39 |
# File 'lib/parse/client/logging.rb', line 37 def enabled @enabled end |
.log_level ⇒ Symbol
Returns The log level (:info, :debug, :warn).
40 41 42 |
# File 'lib/parse/client/logging.rb', line 40 def log_level @log_level end |
.logger ⇒ Logger
Returns The logger instance to use.
43 44 45 |
# File 'lib/parse/client/logging.rb', line 43 def logger @logger end |
.max_body_length ⇒ Integer
Returns Maximum body length to log (defaults to MAX_BODY_LENGTH).
46 47 48 |
# File 'lib/parse/client/logging.rb', line 46 def max_body_length @max_body_length end |
Class Method Details
.current_log_level ⇒ Symbol
Get the current log level (defaults to :info)
69 70 71 |
# File 'lib/parse/client/logging.rb', line 69 def current_log_level log_level || :info end |
.current_logger ⇒ Logger
Get the configured logger or default
63 64 65 |
# File 'lib/parse/client/logging.rb', line 63 def current_logger logger || default_logger end |
.current_max_body_length ⇒ Integer
Get the max body length (defaults to MAX_BODY_LENGTH)
75 76 77 |
# File 'lib/parse/client/logging.rb', line 75 def current_max_body_length max_body_length || MAX_BODY_LENGTH end |
.default_logger ⇒ Logger
Default logger instance
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/parse/client/logging.rb', line 50 def default_logger @default_logger ||= begin l = Logger.new(STDOUT) l.progname = "Parse" l.formatter = proc do |severity, datetime, progname, msg| "[#{progname}] #{msg}\n" end l end end |