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.
35 36 37 |
# File 'lib/parse/client/logging.rb', line 35 def enabled @enabled end |
.log_level ⇒ Symbol
Returns The log level (:info, :debug, :warn).
38 39 40 |
# File 'lib/parse/client/logging.rb', line 38 def log_level @log_level end |
.logger ⇒ Logger
Returns The logger instance to use.
41 42 43 |
# File 'lib/parse/client/logging.rb', line 41 def logger @logger end |
.max_body_length ⇒ Integer
Returns Maximum body length to log (defaults to MAX_BODY_LENGTH).
44 45 46 |
# File 'lib/parse/client/logging.rb', line 44 def max_body_length @max_body_length end |
Class Method Details
.current_log_level ⇒ Symbol
Get the current log level (defaults to :info)
67 68 69 |
# File 'lib/parse/client/logging.rb', line 67 def current_log_level log_level || :info end |
.current_logger ⇒ Logger
Get the configured logger or default
61 62 63 |
# File 'lib/parse/client/logging.rb', line 61 def current_logger logger || default_logger end |
.current_max_body_length ⇒ Integer
Get the max body length (defaults to MAX_BODY_LENGTH)
73 74 75 |
# File 'lib/parse/client/logging.rb', line 73 def current_max_body_length max_body_length || MAX_BODY_LENGTH end |
.default_logger ⇒ Logger
Default logger instance
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/parse/client/logging.rb', line 48 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 |