Class: S3Antivirus::Tee

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Defined in:
lib/s3_antivirus/tee.rb

Instance Method Summary collapse

Constructor Details

#initialize(path, options = {}) ⇒ Tee

Returns a new instance of Tee.



7
8
9
# File 'lib/s3_antivirus/tee.rb', line 7

def initialize(path, options={})
  @path, @options = path, options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, message, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/s3_antivirus/tee.rb', line 11

def method_missing(name, message, &block)
  if logger.respond_to?(name)
    # Interesting note about level mapping: http://bit.ly/2PP5Y6Z
    #   Messages from Ruby applications are not considered as critical as messages
    #   from other system daemons using syslog(3), so most messages are reduced by one level.
    #
    # Will mimic behavior for puts stdout.
    # Interestingly, the default logger.level is ::Logger::DEBUG which is 0.
    # So can't check against that, so will check against the method name.
    puts message unless name == :debug
    logger.send(name, message, &block)
  else
    super
  end
end

Instance Method Details

#loggerObject



27
28
29
# File 'lib/s3_antivirus/tee.rb', line 27

def logger
  Syslog::Logger.new(@path)
end