Sha256: f03ab0266ff8acd2aa433b2bccbe9ad2b4d47dc35da187a3425b8285ec2945e3

Contents?: true

Size: 992 Bytes

Versions: 4

Compression:

Stored size: 992 Bytes

Contents

require 'ns-options'
require 'logging'
require 'logsly/colors'
require 'logsly/base_output'

module Logsly

  module Settings
    include NsOptions::Proxy

    option :colors,  ::Hash, :default => ::Hash.new(NullColors.new)
    option :outputs, ::Hash, :default => ::Hash.new(NullOutput.new)
  end

  def self.reset
    Settings.reset
    Logging.reset
  end

  def self.colors(name, &block)
    require 'logsly/colors'
    Settings.colors[name.to_s] = Colors.new(name, &block) if !block.nil?
    Settings.colors[name.to_s]
  end

  def self.stdout(name, &block)
    require 'logsly/stdout_output'
    Settings.outputs[name.to_s] = StdoutOutput.new(&block)
  end

  def self.file(name, &block)
    require 'logsly/file_output'
    Settings.outputs[name.to_s] = FileOutput.new(&block)
  end

  def self.syslog(name, &block)
    require 'logsly/syslog_output'
    Settings.outputs[name.to_s] = SyslogOutput.new(&block)
  end

  def self.outputs(name)
    Settings.outputs[name.to_s]
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
logsly-1.0.2 lib/logsly/settings.rb
logsly-1.0.1 lib/logsly/settings.rb
logsly-1.0.0 lib/logsly/settings.rb
logsly-1.0.0.rc1 lib/logsly/settings.rb