Module: Parse::LiveQuery::Logging
- Defined in:
- lib/parse/live_query/logging.rb
Overview
Structured logging module for LiveQuery.
Provides leveled logging with context support. Disabled by default.
Constant Summary collapse
- LEVELS =
Log levels in order of verbosity
[:debug, :info, :warn, :error].freeze
Class Attribute Summary collapse
-
.enabled ⇒ Boolean
Whether logging is enabled.
-
.log_level ⇒ Symbol
Current log level (:debug, :info, :warn, :error).
-
.logger ⇒ Logger?
Custom logger instance.
Class Method Summary collapse
-
.current_logger ⇒ Logger
Get the current logger (custom or default).
-
.debug(message, **context) ⇒ Object
Log a debug message.
-
.default_logger ⇒ Logger
Get or create the default logger.
-
.error(message, **context) ⇒ Object
Log an error message.
-
.info(message, **context) ⇒ Object
Log an info message.
-
.reset! ⇒ Object
Reset logging configuration to defaults.
-
.warn(message, **context) ⇒ Object
Log a warning message.
Class Attribute Details
.enabled ⇒ Boolean
Returns whether logging is enabled.
25 26 27 |
# File 'lib/parse/live_query/logging.rb', line 25 def enabled @enabled end |
.log_level ⇒ Symbol
Returns current log level (:debug, :info, :warn, :error).
31 32 33 |
# File 'lib/parse/live_query/logging.rb', line 31 def log_level @log_level end |
.logger ⇒ Logger?
Returns custom logger instance.
28 29 30 |
# File 'lib/parse/live_query/logging.rb', line 28 def logger @logger end |
Class Method Details
.current_logger ⇒ Logger
Get the current logger (custom or default)
57 58 59 |
# File 'lib/parse/live_query/logging.rb', line 57 def current_logger logger || default_logger end |
.debug(message, **context) ⇒ Object
Log a debug message
64 65 66 |
# File 'lib/parse/live_query/logging.rb', line 64 def debug(, **context) log(:debug, , context) end |
.default_logger ⇒ Logger
Get or create the default logger
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/parse/live_query/logging.rb', line 44 def default_logger @default_logger ||= begin l = ::Logger.new($stdout) l.progname = "Parse::LiveQuery" l.formatter = proc do |severity, datetime, progname, msg| "[#{datetime.strftime("%Y-%m-%d %H:%M:%S")}] #{severity} -- #{progname}: #{msg}\n" end l end end |
.error(message, **context) ⇒ Object
Log an error message
85 86 87 |
# File 'lib/parse/live_query/logging.rb', line 85 def error(, **context) log(:error, , context) end |
.info(message, **context) ⇒ Object
Log an info message
71 72 73 |
# File 'lib/parse/live_query/logging.rb', line 71 def info(, **context) log(:info, , context) end |
.reset! ⇒ Object
Reset logging configuration to defaults
90 91 92 93 94 95 |
# File 'lib/parse/live_query/logging.rb', line 90 def reset! @enabled = false @logger = nil @log_level = :info @default_logger = nil end |
.warn(message, **context) ⇒ Object
Log a warning message
78 79 80 |
# File 'lib/parse/live_query/logging.rb', line 78 def warn(, **context) log(:warn, , context) end |