Class: Loog::Tee
- Inherits:
-
Object
- Object
- Loog::Tee
- 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-2023 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #debug(msg) ⇒ Object
- #debug? ⇒ Boolean
- #error(msg) ⇒ Object
- #info(msg) ⇒ Object
- #info? ⇒ Boolean
-
#initialize(*logs) ⇒ Tee
constructor
Makes an instance.
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
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
56 57 58 |
# File 'lib/loog/tee.rb', line 56 def info? @logs.any? { |g| g.info?(msg) } end |