Class: Loog::Tee

Inherits:
Object
  • Object
show all
Defined in:
lib/loog/tee.rb

Overview

A combiner of a few logs together:

require 'loog'
tee = Loog::Tee.new(Loog::VERBOSE, file_logger)
log.info('Hello, world!')

This way you can log to console and to the file at the same time.

Author

Yegor Bugayenko ([email protected])

Copyright

Copyright © 2018 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(*logs) ⇒ Tee

Makes an instance.



40
41
42
# File 'lib/loog/tee.rb', line 40

def initialize(*logs)
  @logs = logs
end

Instance Method Details

#debug(msg) ⇒ Object



44
45
46
# File 'lib/loog/tee.rb', line 44

def debug(msg)
  @logs.each { |g| g.debug(msg) }
end

#debug?Boolean

Returns:

  • (Boolean)


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

def debug?
  @logs.any? { |g| g.debug?(msg) }
end

#error(msg) ⇒ Object



60
61
62
# File 'lib/loog/tee.rb', line 60

def error(msg)
  @logs.each { |g| g.error(msg) }
end

#info(msg) ⇒ Object



52
53
54
# File 'lib/loog/tee.rb', line 52

def info(msg)
  @logs.each { |g| g.info(msg) }
end

#info?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/loog/tee.rb', line 56

def info?
  @logs.any? { |g| g.info?(msg) }
end