Class Needle::LoggingInterceptor
In: lib/needle/logging-interceptor.rb
Parent: Object

A LoggingInterceptor is an interceptor object that logs method invocations and exceptions. It includes the IncludeExclude functionality.

Methods

new   process  

Included Modules

IncludeExclude

Public Class methods

Create a new LoggingInterceptor for the given service point, with the given list of include and exclude patterns. The logger object will be created as well, named with the service point’s full name.

[Source]

    # File lib/needle/logging-interceptor.rb, line 29
29:     def initialize( point, parms )
30:       @log = point.container.logs.get( point.fullname )
31: 
32:       @includes = build_map( parms[ :include ] )
33:       @excludes = build_map( parms[ :exclude ] )
34:     end

Public Instance methods

Processes a method invocation context. If the current log has debugging activated, and the requested method is not excluded by the interceptor’s exclude and include patterns, then a message will be written for the method’s invocation, its return code, and any exception that is thrown.

[Source]

    # File lib/needle/logging-interceptor.rb, line 41
41:     def process( chain, context )
42:       if @log.debug? && match( context )
43:         args = context.args.map { |i| i.inspect } .join( ', ' )
44:         @log.debug "#{context.sym}( #{args} )"
45: 
46:         begin
47:           result = chain.process_next( context )
48:         rescue Exception => e
49:           @log.debug "#{context.sym} raised #{e.message.inspect} (#{e.class})"
50:           raise
51:         end
52: 
53:         @log.debug "#{context.sym} => #{result.inspect}"
54:         return result
55:       else
56:         return chain.process_next( context )
57:       end
58:     end

[Validate]