class Telegram::BotManager::Logger::MultiIO

Public Class Methods

new(*targets) click to toggle source
# File lib/telegram/bot_manager/logger.rb, line 11
def initialize(*targets)
  @targets = targets.compact
end

Public Instance Methods

close() click to toggle source
# File lib/telegram/bot_manager/logger.rb, line 29
def close
  @targets.each(&:close)
end
write(*args) click to toggle source
# File lib/telegram/bot_manager/logger.rb, line 15
def write(*args)
  @targets.each do |target|
    if target.is_a?(File)
      # Remove colorization
      args.map! { |a| a.gsub(/\e\[(\d+)(;\d+)*m/, '') }

      target.write(*args)
      target.rewind
    else
      target.write(*args)
    end
  end
end