Module: RailsErrorDashboard::Logger

Defined in:
lib/rails_error_dashboard/logger.rb

Overview

Internal logger wrapper for Rails Error Dashboard

By default, all logging is SILENT to keep production logs clean. Users can opt-in to verbose logging for debugging.

Examples:

Enable logging for debugging

RailsErrorDashboard.configure do |config|
  config.enable_internal_logging = true
  config.log_level = :debug
end

Production troubleshooting (errors only)

RailsErrorDashboard.configure do |config|
  config.enable_internal_logging = true
  config.log_level = :error
end

Constant Summary collapse

LOG_LEVELS =
{
  debug: 0,
  info: 1,
  warn: 2,
  error: 3,
  silent: 4
}.freeze

Class Method Summary collapse

Class Method Details

.debug(message) ⇒ Object

Log debug message (only if internal logging enabled)

Examples:

RailsErrorDashboard::Logger.debug("Processing error #123")

Parameters:

  • message (String)

    The message to log



35
36
37
38
39
40
# File 'lib/rails_error_dashboard/logger.rb', line 35

def debug(message)
  return unless logging_enabled?
  return unless log_level_enabled?(:debug)

  Rails.logger.debug(formatted_message(message))
end

.error(message) ⇒ Object

Log error message Errors are logged by default unless log_level is :silent

Examples:

RailsErrorDashboard::Logger.error("Failed to save error log")

Parameters:

  • message (String)

    The message to log



72
73
74
75
76
# File 'lib/rails_error_dashboard/logger.rb', line 72

def error(message)
  return unless log_level_enabled?(:error)

  Rails.logger.error(formatted_message(message))
end

.info(message) ⇒ Object

Log info message (only if internal logging enabled)

Examples:

RailsErrorDashboard::Logger.info("Registered plugin: MyPlugin")

Parameters:

  • message (String)

    The message to log



47
48
49
50
51
52
# File 'lib/rails_error_dashboard/logger.rb', line 47

def info(message)
  return unless logging_enabled?
  return unless log_level_enabled?(:info)

  Rails.logger.info(formatted_message(message))
end

.warn(message) ⇒ Object

Log warning message (only if internal logging enabled)

Examples:

RailsErrorDashboard::Logger.warn("Plugin already registered")

Parameters:

  • message (String)

    The message to log



59
60
61
62
63
64
# File 'lib/rails_error_dashboard/logger.rb', line 59

def warn(message)
  return unless logging_enabled?
  return unless log_level_enabled?(:warn)

  Rails.logger.warn(formatted_message(message))
end