Class: Needle::LoggingInterceptor

### Home Classes Methods

### In Files

- lib/needle/logging-interceptor.rb

### Parent

Object

### Methods

- ::new
- #process

### Included Modules

- Needle::IncludeExclude

### Files

- README

### Class/Module Index

Quicksearch

- Needle
- Needle::Bug
- Needle::Container
- Needle::DefinitionContext
- Needle::IncludeExclude
- Needle::Interceptor
- Needle::Interceptor::DynamicInterceptor
- Needle::InterceptorChainBuilder
- Needle::InterceptorChainBuilder::InterceptedServiceProxy
- Needle::InterceptorChainBuilder::InterceptorChainElement
- Needle::InterceptorChainBuilder::ProxyObjectChainElement
- Needle::InterceptorConfigurationError
- Needle::Lifecycle
- Needle::Lifecycle::Deferred
- Needle::Lifecycle::Initialize
- Needle::Lifecycle::Multiton
- Needle::Lifecycle::Proxy
- Needle::Lifecycle::Singleton
- Needle::Lifecycle::Threaded
- Needle::LogFactory
- Needle::Logger
- Needle::LoggingInterceptor
- Needle::NeedleError
- Needle::Pipeline
- Needle::Pipeline::Collection
- Needle::Pipeline::Collection::BlockElement
- Needle::Pipeline::Element
- Needle::Pipeline::InterceptorElement
- Needle::QueryableMutex
- Needle::Registry
- Needle::ServiceNotFound
- Needle::ServicePoint
- Needle::Version

No matching classes.

# Needle::LoggingInterceptor

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

### Public Class Methods

new( point, parms ) click to toggle source

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.

    # File lib/needle/logging-interceptor.rb, line 29
    def initialize( point, parms )
      @log = point.container.logs.get( point.fullname )

      @includes = build_map( parms[ :include ] )
      @excludes = build_map( parms[ :exclude ] )
    end

### Public Instance Methods

process( chain, context ) click to toggle source

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.

    # File lib/needle/logging-interceptor.rb, line 41
    def process( chain, context )
      if @log.debug? && match( context )
        args = context.args.map { |i| i.inspect } .join( ', ' )
        @log.debug "#{context.sym}( #{args} )"

        begin
          result = chain.process_next( context )
        rescue Exception => e
          @log.debug "#{context.sym} raised #{e.message.inspect} (#{e.class})"
          raise
        end

        @log.debug "#{context.sym} => #{result.inspect}"
        return result
      else
        return chain.process_next( context )
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.