Class: Tracing::StreamAppender

Inherits:
BaseAppender show all
Defined in:
lib/appenders/types/stream_appender.rb

Instance Attribute Summary collapse

Attributes inherited from BaseAppender

#options, #templates

Attributes included from FilterUse

#filters

Attributes included from Filter::ExecUse

#filter_executor

Attributes included from Filter::Registration

#filters

Instance Method Summary collapse

Methods inherited from BaseAppender

create_template, #handle, register_templates, #time_limit

Methods included from Filter::Registration

#_register_filters, #create_filters, #register_filters, #unregister_filters

Constructor Details

#initialize(init_options) ⇒ StreamAppender



15
16
17
18
19
# File 'lib/appenders/types/stream_appender.rb', line 15

def initialize(init_options)
  @tracer = Tracing::OutputTemplate::StringTrace.new      
  super(init_options)
  configure_stream(init_options)                        
end

Instance Attribute Details

#streamObject

Returns the value of attribute stream.



3
4
5
# File 'lib/appenders/types/stream_appender.rb', line 3

def stream
  @stream
end

Instance Method Details

#allow_append(txt, context) ⇒ Object

perform append



22
23
24
25
26
27
28
29
30
31
# File 'lib/appenders/types/stream_appender.rb', line 22

def allow_append(txt, context)
  # check if BEGIN or END
  if txt.include?('BEGIN')
    txt = tracer.handle_before_call(context)
  elsif txt.include?('END')
    txt = tracer.handle_after_call(context)
  end
  
  stream.puts txt
end

#configure_stream(options) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/appenders/types/stream_appender.rb', line 5

def configure_stream(options)
  @stream = $stdout            
  if options
    case options[:stream]
      when :error
        @stream = $stderr      
    end
  end
end

#not_allow_append(lines, context) ⇒ Object

silently ignore



34
35
# File 'lib/appenders/types/stream_appender.rb', line 34

def not_allow_append(lines, context)
end