Sha256: fa0ba9e7ab3ad7ad5b355f8499ef57a325eba0941874a262c6779141bced963c

Contents?: true

Size: 1.75 KB

Versions: 19

Compression:

Stored size: 1.75 KB

Contents

require 'active_support/log_subscriber'

# A wrapper for slingshot  elastic-search adapter for Mongoid
module Mebla
  # Handles logging
  class LogSubscriber < ActiveSupport::LogSubscriber
    # Debug message
    def mebla_debug(event)
      debug_green event.payload[:message]      
    end

    # Error message
    def mebla_error(event)
      error_red event.payload[:message]      
    end
    
    # Info message    
    def mebla_info(event)
      info_blue event.payload[:message]      
    end
    
    # Fatal message
    def mebla_fatal(event)
      fatal_magenta event.payload[:message]      
    end

    # Warning message
    def mebla_warn(event)
      warn_yellow event.payload[:message]      
    end
    
    # Unknown message
    def mebla_unknown(event)
      unknown event.payload[:message]      
    end
    
    # --
    # -------------------------------------------------------------
    # Add some colors
    # -------------------------------------------------------------
    # ++
    
    # Print a debug message to the log file
    def debug_green(msg)
      debug color(msg, LogSubscriber::GREEN)
    end
    
    # Print an error message to the log file
    def error_red(msg)
      error color(msg, LogSubscriber::RED)
    end
    
    # Print an info message to the log file
    def info_blue(msg)
      info color(msg, LogSubscriber::BLUE)
    end
    
    # Print a fatal message to the log file
    def fatal_magenta(msg)
      fatal color(msg, LogSubscriber::MAGENTA)
    end
    
    # Print a warn message to the log file
    def warn_yellow(msg)
      warn color(msg, LogSubscriber::YELLOW)
    end
    
    # Returns the main logger for Mebla
    # @return [Logger]
    def self.logger
      Mebla::Configuration.instance.logger
    end
  end    
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
rmla-1.0 lib/mebla/log_subscriber.rb
mebla-1.1.14 lib/mebla/log_subscriber.rb
mebla-1.1.13 lib/mebla/log_subscriber.rb
mebla-1.1.12 lib/mebla/log_subscriber.rb
mebla-1.1.11 lib/mebla/log_subscriber.rb
mebla-1.1.10 lib/mebla/log_subscriber.rb
mebla-1.1.9 lib/mebla/log_subscriber.rb
mebla-1.1.8 lib/mebla/log_subscriber.rb
mebla-1.1.7 lib/mebla/log_subscriber.rb
mebla-1.1.6 lib/mebla/log_subscriber.rb
mebla-1.1.5 lib/mebla/log_subscriber.rb
mebla-1.1.4 lib/mebla/log_subscriber.rb
mebla-1.1.2 lib/mebla/log_subscriber.rb
mebla-1.1.1 lib/mebla/log_subscriber.rb
mebla-1.1.0 lib/mebla/log_subscriber.rb
mebla-1.0.3 lib/mebla/log_subscriber.rb
mebla-1.0.2 lib/mebla/log_subscriber.rb
mebla-1.0.1 lib/mebla/log_subscriber.rb
mebla-1.0.0 lib/mebla/log_subscriber.rb