Class: Loog::Tee

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

Overview

A combiner of a few logs together:

require 'loog' require 'loog/tee' tee = Loog::Tee.new(Loog::VERBOSE, file_logger) tee.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 (c) 2018-2026 Yegor Bugayenko

License

MIT

Instance Method Summary collapse

Constructor Details

#initialize(*logs) ⇒ Tee

Makes an instance.



22
23
24
# File 'lib/loog/tee.rb', line 22

def initialize(*logs)
  @logs = logs
end

Instance Method Details

#debug(msg) ⇒ Object



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

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

#debug?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/loog/tee.rb', line 30

def debug?
  @logs.any?(&:debug?)
end

#error(msg) ⇒ Object



50
51
52
# File 'lib/loog/tee.rb', line 50

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

#error?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/loog/tee.rb', line 54

def error?
  @logs.any?(&:error?)
end

#info(msg) ⇒ Object



34
35
36
# File 'lib/loog/tee.rb', line 34

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

#info?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/loog/tee.rb', line 38

def info?
  @logs.any?(&:info?)
end

#warn(msg) ⇒ Object



42
43
44
# File 'lib/loog/tee.rb', line 42

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

#warn?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/loog/tee.rb', line 46

def warn?
  @logs.any?(&:warn?)
end