Sha256: 81d87bd573460a23f68906a76dcda94740832760c3c0c681cc94b92a995e17a4

Contents?: true

Size: 1.74 KB

Versions: 12

Compression:

Stored size: 1.74 KB

Contents

#
# Fluent
#
# Copyright (C) 2011 FURUHASHI Sadayuki
#
#    Licensed under the Apache License, Version 2.0 (the "License");
#    you may not use this file except in compliance with the License.
#    You may obtain a copy of the License at
#
#        http://www.apache.org/licenses/LICENSE-2.0
#
#    Unless required by applicable law or agreed to in writing, software
#    distributed under the License is distributed on an "AS IS" BASIS,
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
module Fluent

module Logger
  autoload :ConsoleLogger , 'fluent/logger/console_logger'
  autoload :FluentLogger  , 'fluent/logger/fluent_logger'
  autoload :LoggerBase    , 'fluent/logger/logger_base'
  autoload :TestLogger    , 'fluent/logger/test_logger'
  autoload :TextLogger    , 'fluent/logger/text_logger'
  autoload :NullLogger    , 'fluent/logger/null_logger'
  autoload :VERSION       , 'fluent/logger/version'

  @@default_logger = nil

  def self.new(*args)
    if args.first.is_a?(Class) && args.first.ancestors.include?(LoggerBase)
      type = args.shift
    else
      type = FluentLogger
    end
    type.new(*args)
  end

  def self.open(*args)
    close
    @@default_logger = new(*args)
  end

  def self.close
    if @@default_logger
      @@default_logger.close
      @@default_logger = nil
    end
  end

  def self.post(tag, map)
    @@default_logger.post(tag, map)
  end

  def self.post_with_time(tag, map, time)
    @@default_logger.post_with_time(tag, map, time)
  end

  def self.default
    @@default_logger ||= ConsoleLogger.new(STDOUT)
  end

  def self.default=(logger)
    @@default_logger = logger
  end
end

end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
fluent-logger-0.4.10 lib/fluent/logger.rb
fluent-logger-0.4.9 lib/fluent/logger.rb
fluent-logger-0.4.8 lib/fluent/logger.rb
jmoses_fluent-logger-0.4.10 lib/fluent/logger.rb
jmoses_fluent-logger-0.4.9 lib/fluent/logger.rb
jmoses_fluent-logger-0.4.8 lib/fluent/logger.rb
fluent-logger-0.4.7 lib/fluent/logger.rb
fluent-logger-0.4.6 lib/fluent/logger.rb
fluent-logger-0.4.5 lib/fluent/logger.rb
fluent-logger-0.4.4 lib/fluent/logger.rb
fluent-logger-0.4.3 lib/fluent/logger.rb
fluent-logger-0.4.2 lib/fluent/logger.rb