Class: HttpStreamingClient::CustomLoggerInternal

Inherits:
Object
  • Object
show all
Defined in:
lib/http_streaming_client/custom_logger.rb

Instance Method Summary collapse

Constructor Details

#initializeCustomLoggerInternal

Returns a new instance of CustomLoggerInternal.



58
59
60
61
# File 'lib/http_streaming_client/custom_logger.rb', line 58

def initialize
  @console = nil
  @logfile = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/http_streaming_client/custom_logger.rb', line 63

def method_missing(name, *args)
  if !@console.nil?
	@console.method(name).call(args) unless name.to_s =~ /(unknown|fatal|error|warn|info|debug)/
	@console.method(name).call(args[0])
  end
  @logfile.method(name).call(args[0]) unless @logfile.nil?
end

Instance Method Details

#console=(enable) ⇒ Object



78
79
80
81
82
83
# File 'lib/http_streaming_client/custom_logger.rb', line 78

def console=(enable)
  return (@console = nil) if !enable
  @console = Logger.new(STDOUT)
  @console.formatter = BasicLogFormatter.new
  @console.level = Logger::INFO
end

#logfile=(enable) ⇒ Object



71
72
73
74
75
76
# File 'lib/http_streaming_client/custom_logger.rb', line 71

def logfile=(enable)
  return (@logfile = nil) if !enable
  @logfile = Logger.new("test.log")
  @logfile.formatter = BasicLogFormatter.new
  @logfile.level = Logger::DEBUG
end

#tag=(tag) ⇒ Object



85
86
87
88
# File 'lib/http_streaming_client/custom_logger.rb', line 85

def tag=(tag)
  @console.formatter.tag = tag unless @console.nil?
  @logfile.formatter.tag = tag unless @logfile.nil?
end