Module: Flnt

Defined in:
lib/flnt.rb,
lib/flnt/logger.rb,
lib/flnt/version.rb,
lib/flnt/configuration.rb,
lib/flnt/teeable_logger.rb

Defined Under Namespace

Modules: Configuration Classes: Logger, TeeableLogger

Constant Summary collapse

VERSION =
"0.5.0"

Class Method Summary collapse

Class Method Details

.ConfigurationObject



33
34
35
# File 'lib/flnt/configuration.rb', line 33

def self.Configuration
  Configuration.to_fluentd_config
end

.initialize!(force = false) ⇒ Object



30
31
32
33
34
35
# File 'lib/flnt.rb', line 30

def initialize!(force=false)
  if force or ( !initialized? and !test_mode? )
    @initialized = true
    Fluent::Logger::FluentLogger.open(*Flnt::Configuration())
  end
end

.initialized?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/flnt.rb', line 26

def initialized?
  !! @initialized
end

.method_missing(name, *args) ⇒ Object



21
22
23
24
# File 'lib/flnt.rb', line 21

def method_missing(name, *args)
  return super if name.to_s =~ /(!|\?)$/
  Flnt::Logger.new(name.to_s)
end

.tag!(tag) ⇒ Object



37
38
39
# File 'lib/flnt.rb', line 37

def tag!(tag)
  Flnt::Logger.new(tag.to_s)
end

.test_mode!Object

This is useful for testing



42
43
44
45
46
# File 'lib/flnt.rb', line 42

def test_mode!
  @test_mode = true
  # Switch the default logger
  ::Fluent::Logger.open(::Fluent::Logger::TestLogger)
end

.test_mode?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/flnt.rb', line 48

def test_mode?
  @test_mode || false
end