Sha256: 23e1e004c0e1b8e5467f6e700d93a034e83019fae7b9d82295de3e62c39ff061

Contents?: true

Size: 1.32 KB

Versions: 12

Compression:

Stored size: 1.32 KB

Contents

# coding: utf-8

# base Splash module
module Splash

  # Splash Loggers module
  module Loggers

    # Dual multiplexer specific logger
    # log against CLi and Daemon
    class Dual #< Splash::Loggers::LoggerTemplate


      include Splash::Config

      # build levels and alias forwarders
      LEVELS.each do |method|
        define_method(method) do |message,session = ''|
            self.log({ :level => method, :message => message, :session => session})
        end
      end
      ALIAS.keys.each do |method|
        define_method(method) do |message,session = ''|
            self.log({ :level => method, :message => message, :session => session})
        end
      end

      # Constructor build two attributes for each loggers : Cli, Daemon
      def initialize
        super
        @log1 = Splash::Loggers::Cli::new
        @log2 = Splash::Loggers::Daemon::new
      end

      def log(options)
        @log1.log options
        @log2.log options
      end

      # getter for root level
      # @return [Symbol] a level
      def level
        @level
      end

      # setter for global level, both Cli and Daemon
      # @param [Symbol] level a level in Splash::Loggers::LEVELS or Splash::Loggers::ALIAS
      def level=(level)
        @level = level
        @log1.level=level
        @log2.level=level
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
prometheus-splash-0.9.1 lib/splash/loggers/dual.rb
prometheus-splash-0.9.0 lib/splash/loggers/dual.rb
prometheus-splash-0.8.6 lib/splash/loggers/dual.rb
prometheus-splash-0.8.5 lib/splash/loggers/dual.rb
prometheus-splash-0.8.4 lib/splash/loggers/dual.rb
prometheus-splash-0.8.3 lib/splash/loggers/dual.rb
prometheus-splash-0.8.2 lib/splash/loggers/dual.rb
prometheus-splash-0.8.1 lib/splash/loggers/dual.rb
prometheus-splash-0.8.0 lib/splash/loggers/dual.rb
prometheus-splash-0.7.0 lib/splash/loggers/dual.rb
prometheus-splash-0.6.1 lib/splash/loggers/dual.rb
prometheus-splash-0.6.0 lib/splash/loggers/dual.rb