Sha256: 0cd8f6b827d10a12618dd7933e627040470d132b9007d6b691fdc81ea6b49ae6

Contents?: true

Size: 676 Bytes

Versions: 9

Compression:

Stored size: 676 Bytes

Contents

require_relative '../lib/lager'

class Foo
  extend Lager

  # set logging from within, useful for default behavior
  #
  log_to $stdout, :warn

  def self.bar
    @lager.debug { "inside Foo.bar" }
  end

  def initialize
    # assign @lager at the instance layer if you want to use it
    # @lager, here, is technically a different variable than used above
    # though we are setting them to the same thing
    #
    @lager = self.class.lager
    @lager.debug { "inside Foo#initialize" }
  end
end

if __FILE__ == $0
  Foo.bar
  Foo.new

  # set logging from outside
  #
  puts "Turning on debug logging"
  Foo.log_to $stderr
  Foo.log_level :debug

  Foo.bar
  Foo.new
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
lager-1.1.3.1 examples/foo.rb
lager-1.1.2.1 examples/foo.rb
lager-1.1.0.1 examples/foo.rb
lager-1.0.0.3 examples/foo.rb
lager-1.0.0.1 examples/foo.rb
lager-0.2.0.9 examples/foo.rb
lager-0.2.0.8 examples/foo.rb
lager-0.2.0.6 examples/foo.rb
lager-0.2.0.5 examples/foo.rb