trace-util-adv 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. data/Advanced TraceUtils tutorial.pdf +0 -0
  2. data/CHANGELOG +4 -8
  3. data/{lib/TODO.txt → TODO.txt} +8 -0
  4. data/VERSION +1 -1
  5. data/lib/action_handler/action_handler.rb +40 -0
  6. data/lib/{action_handler.rb → action_handler/action_handler_registration.rb} +3 -41
  7. data/lib/appenders/appender.rb +1 -13
  8. data/lib/appenders/appender_mappings.rb +13 -0
  9. data/lib/appenders/base_appender.rb +2 -11
  10. data/lib/appenders/file_appender.rb +21 -13
  11. data/lib/appenders/include.rb +4 -0
  12. data/lib/appenders/types/README-NOTE.txt +2 -0
  13. data/lib/appenders/{html_appender.rb → types/html_appender.rb} +4 -20
  14. data/lib/appenders/{logger_appender.rb → types/logger_appender.rb} +0 -0
  15. data/lib/appenders/{stream_appender.rb → types/stream_appender.rb} +0 -0
  16. data/lib/appenders/{template_log_appender.rb → types/template_log_appender.rb} +0 -0
  17. data/lib/appenders/{xml_appender.rb → types/xml_appender.rb} +1 -1
  18. data/lib/extensions/array_extensions.rb +42 -0
  19. data/lib/extensions/hash_extensions.rb +181 -0
  20. data/lib/extensions/hash_rule_extensions.rb +50 -0
  21. data/lib/extensions/include.rb +1 -0
  22. data/lib/extensions/nilclass_extensions.rb +10 -0
  23. data/lib/extensions/object_extensions.rb +19 -0
  24. data/lib/extensions/string_extensions.rb +35 -0
  25. data/lib/extensions/symbol_extensions.rb +30 -0
  26. data/lib/filters/composite/composite_class_filter.rb +25 -0
  27. data/lib/filters/composite/composite_module_filter.rb +53 -0
  28. data/lib/filters/executor/filter_exec.rb +74 -0
  29. data/lib/filters/filter.rb +43 -0
  30. data/lib/filters/filter_factory.rb +1 -1
  31. data/lib/filters/filter_mappings.rb +36 -0
  32. data/lib/filters/{tracing_filter.rb → filter_registration.rb} +6 -49
  33. data/lib/filters/filter_use.rb +10 -0
  34. data/lib/filters/include.rb +8 -0
  35. data/lib/filters/list/README-NOTE.txt +1 -0
  36. data/lib/filters/list/list_instance_var_filter.rb +27 -0
  37. data/lib/filters/{message_filters.rb → msg_context/message_context_filters.rb} +3 -12
  38. data/lib/filters/simple/argument_filter.rb +24 -0
  39. data/lib/filters/simple/class_filter.rb +15 -0
  40. data/lib/filters/simple/instance_var_filter.rb +25 -0
  41. data/lib/filters/simple/method_filter.rb +17 -0
  42. data/lib/filters/simple/module_filter.rb +14 -0
  43. data/lib/{templates/trace_output_handler.rb → output_handler/output_handler.rb} +0 -0
  44. data/lib/rules/rule_mappings.rb +10 -0
  45. data/lib/{rule_match.rb → rules/rule_match.rb} +5 -3
  46. data/lib/targets/README-NOTE.txt +2 -0
  47. data/lib/targets/file_target.rb +65 -0
  48. data/lib/targets/stream_target.rb +9 -0
  49. data/lib/targets/string_target.rb +9 -0
  50. data/lib/templates/base_template.rb +3 -2
  51. data/lib/templates/html_template.rb +1 -2
  52. data/lib/templates/include.rb +2 -0
  53. data/lib/templates/string_template.rb +24 -25
  54. data/lib/templates/template_mappings.rb +10 -0
  55. data/lib/templates/xml_template.rb +28 -29
  56. data/lib/trace-util-adv.rb +24 -4
  57. data/lib/{trace_calls.rb → trace_calls/trace_calls.rb} +0 -0
  58. data/lib/trace_calls/trace_configuration.rb +29 -0
  59. data/lib/{trace_ext.rb → trace_calls/trace_ext.rb} +10 -9
  60. data/test/{test_action_handler.rb → action_handler/test_action_handler.rb} +1 -5
  61. data/test/action_handler/test_create_action_handler.rb +31 -0
  62. data/test/appenders/test_appender_filters.rb +0 -0
  63. data/test/appenders/test_appender_tracers.rb +56 -0
  64. data/test/appenders/test_create_appender.rb +49 -0
  65. data/test/{test_html_appender.rb → appenders/test_html_appender.rb} +3 -7
  66. data/test/appenders/test_stream_appender.rb +41 -0
  67. data/test/appenders/test_template_log_appender.rb +18 -0
  68. data/test/{test_xml_appender.rb → appenders/test_xml_appender.rb} +0 -0
  69. data/test/extensions/test_filters_creation.rb +36 -0
  70. data/test/extensions/test_hash_extensions.rb +208 -0
  71. data/test/extensions/test_hash_filter_extensions.rb +65 -0
  72. data/test/extensions/test_set_context.rb +94 -0
  73. data/test/extensions/test_string_extensions.rb +55 -0
  74. data/test/extensions/test_symbol_extensions.rb +35 -0
  75. data/test/{test_filters_chain.rb → filters/chain/test_filters_chain.rb} +2 -1
  76. data/test/filters/composite/test_composite_class_filter.rb +78 -0
  77. data/test/filters/composite/test_composite_module_filter.rb +82 -0
  78. data/test/filters/composite/test_composite_var_filter.rb +103 -0
  79. data/test/filters/executor/test_filter_exec.rb +80 -0
  80. data/test/filters/msg_context/test_custom_filters.rb +54 -0
  81. data/test/filters/simple/test_base_filter.rb +56 -0
  82. data/test/filters/simple/test_class_filter.rb +75 -0
  83. data/test/filters/simple/test_instancevar_filter.rb +82 -0
  84. data/test/filters/simple/test_method_filter.rb +77 -0
  85. data/test/filters/simple/test_module_filter.rb +63 -0
  86. data/test/samples/include.rb +1 -0
  87. data/test/samples/sample_classes.rb +23 -0
  88. data/test/samples/sample_composite_filters.rb +50 -0
  89. data/test/samples/sample_filters.rb +58 -0
  90. data/test/sandbox/matcher.rb +7 -0
  91. data/test/sandbox/sandbox.rb +25 -0
  92. data/test/{test_xml_gen.rb → sandbox/test_xml_gen.rb} +0 -0
  93. data/test/trace_calls/test_configure_.rb +70 -0
  94. data/test/trace_calls/tracing/test_html_tracing.rb +20 -0
  95. data/test/trace_calls/tracing/test_logger_tracing.rb +18 -0
  96. data/test/trace_calls/tracing/test_stream_tracing.rb +17 -0
  97. data/test/trace_calls/tracing/test_teamplate_log_tracing.rb +18 -0
  98. data/test/trace_calls/tracing/test_xml_tracing.rb +18 -0
  99. data/test/tracers/test_create_tracers.rb +46 -0
  100. data/test/tracers/test_exec_tracers.rb +11 -0
  101. data/trace-util-adv.gemspec +91 -32
  102. metadata +91 -32
  103. data/lib/core_extensions.rb +0 -101
  104. data/lib/filters/base_filters.rb +0 -178
  105. data/lib/filters/composite_filters.rb +0 -71
  106. data/lib/output_templates.rb +0 -5
  107. data/lib/sample_filters.rb +0 -97
  108. data/lib/trace_appenders.rb +0 -9
  109. data/lib/trace_filters.rb +0 -4
  110. data/test/test_appender.rb +0 -29
  111. data/test/test_file_appender.rb +0 -32
  112. data/test/test_filters.rb +0 -112
  113. data/test/test_filters_create.rb +0 -28
  114. data/test/test_special_filters.rb +0 -78
@@ -1,101 +0,0 @@
1
- require 'rule_match'
2
-
3
- class String
4
- def modules
5
- self.split("::")[0..-2]
6
- end
7
-
8
- def class_name
9
- self.split("::")[-1..-1]
10
- end
11
-
12
- def in_module?(module_name)
13
- modules = self.modules
14
- modules.include?(module_name)
15
- end
16
-
17
- def split_names
18
- self.split(/\s|,/)
19
- end
20
-
21
- end
22
-
23
-
24
- class Array
25
- include Tracing::RuleMatch
26
-
27
- def add(obj)
28
- self << obj
29
- self.flatten!
30
- end
31
- end
32
-
33
- class Symbol
34
- def prefix(pre)
35
- (pre.to_s + self.to_s).to_sym
36
- end
37
- end
38
-
39
- class Hash
40
- include Tracing::RuleMatch
41
-
42
- def try_create_filter(symbol)
43
- isymbol = has_i(symbol) || has_x(symbol)
44
- # puts "try_create_filter: " + isymbol.inspect
45
- if isymbol
46
- filter_names = self[isymbol]
47
- # puts "filter_names:" + filter_names.inspect
48
- {symbol => {:include => filter_names}}
49
- end
50
- end
51
-
52
- def rules_allow_action(name)
53
- rule_allow_action(name)
54
- end
55
-
56
- def rule_list(rules)
57
- if rules.kind_of? String
58
- rules.split_names
59
- else
60
- rules
61
- end
62
- end
63
-
64
- # return a symbol, either - :include, :exclude or :yield (let next filter decide)
65
- def rule_allow_action(name)
66
- include_rules = rule_list(self[:include])
67
- if include_rules && include_rules.size > 0
68
- # puts "Rule include"
69
- res = include_rules.matches_any?(name)
70
- return :include if res
71
- end
72
- exclude_rules = rule_list(self[:exclude])
73
- if exclude_rules
74
- # puts "Rule exclude"
75
- return :exclude if exclude_rules.matches_any?(name)
76
- end
77
- # puts "Not included or excluded"
78
- if !self[:default].nil?
79
- # puts "Return default: #{self[:default]}"
80
- return self[:default]
81
- end
82
- # puts "Rule yields"
83
- return :yield
84
- rescue RuleTypeError
85
- # puts "error"
86
- return :exclude
87
- end
88
-
89
- protected
90
- def has_i(symbol)
91
- isym = symbol.prefix('i')
92
- self.has_key?(isym) ? isym : false
93
- end
94
-
95
- def has_x(symbol)
96
- self.has_key?(symbol.prefix('i'))
97
- end
98
-
99
- end
100
-
101
-
@@ -1,178 +0,0 @@
1
- module Tracing
2
-
3
- # abstract filter
4
- class BaseFilter
5
- attr_reader :name
6
- attr_accessor :rules
7
-
8
- class << self
9
- attr_accessor :filters
10
-
11
- # register symbol => filter mappings
12
- def register_filters(hash)
13
- filters.merge!(hash)
14
- end
15
-
16
- # array of symbols
17
- # [:special_filter, :stream_filter]
18
- def unregister_filters(hash)
19
- filters.reject!{|key, value| hash.include? key}
20
- end
21
-
22
- def filter_rule_mappings
23
- {
24
- :module_rules => :module_filter,
25
- :class_rules => :class_filter,
26
- :method_rules => :method_filter,
27
- :var_rules => :vars_filter,
28
- :modules => :composite_module_filter,
29
- :classes => :composite_class_filter,
30
- :vars => :composite_vars_filter
31
- }
32
- end
33
-
34
- def convenience_map
35
- {
36
- :module => :module_filter,
37
- :class => :class_filter,
38
- :method => :method_filter,
39
- :vars => :vars_filter,
40
- }
41
- end
42
-
43
-
44
- def default_filters
45
- {
46
- :module_filter => Tracing::ModuleFilter,
47
- :class_filter => Tracing::ClassFilter,
48
- :method_filter => Tracing::MethodFilter,
49
- :vars_filter => Tracing::InstanceVarFilter,
50
- :composite_module_filter => Tracing::CompositeModuleFilter,
51
- :composite_class_filter => Tracing::CompositeClassFilter,
52
- :composite_vars_filter => Tracing::CompositeInstanceVarFilter
53
- }
54
- end
55
-
56
- def get_filter(options)
57
- convenience_map.select do |key, _filter|
58
- return _filter if options.has_key?(key) || options.has_key?(_filter)
59
- end
60
- filter_rule_mappings.select do |key, _filter|
61
- return _filter if options.has_key? key
62
- end
63
- return options
64
- end
65
-
66
- # Example:
67
- # {:method, :include => 'hello,way'}
68
- # {:class, :include => 'A,B', :exclude => 'C'}
69
- def filter_by_hash(options)
70
- filters ||= default_filters
71
-
72
- # try by factory
73
- new_filter = Tracing::Filter.create_filter(options)
74
-
75
- # puts "New filter: #{new_filter.inspect}"
76
-
77
- options = new_filter if new_filter
78
-
79
- # try by other means
80
- type = get_filter(options)
81
-
82
- if type && type.kind_of?(Symbol)
83
- filter_class = filters[type]
84
-
85
- # puts "filter class: #{filter_class}"
86
-
87
- # ensure options has rules
88
- if filter_class
89
- filter_class.new(options)
90
- else
91
- raise Exception, "Filterclass not found"
92
- end
93
- end
94
- end
95
-
96
- # TODO: Refactor using symbol map!
97
- def create_filter(options)
98
- if options.kind_of? Hash
99
- _filter = filter_by_hash(options)
100
- elsif options.kind_of? BaseFilter
101
- options
102
- else
103
- nil
104
- end
105
- end
106
-
107
- end
108
-
109
- def initialize(options)
110
- @name = options[:name] || "Unknown filter"
111
- end
112
-
113
- def name_allow_action(name)
114
- res = rules.rules_allow_action(name)
115
- end
116
- end
117
-
118
- # filter on module
119
- class ModuleFilter < BaseFilter
120
- def initialize(options)
121
- super(options)
122
- @rules = options[:module_rules] || {}
123
- end
124
-
125
- def allow_action(msg, context)
126
- name = context[:full_module_name]
127
- allow = name_allow_action(name)
128
- end
129
- end
130
-
131
- # filter on class name
132
- class ClassFilter < BaseFilter
133
- def initialize(options)
134
- super(options)
135
- @rules = options[:class_rules] || {}
136
- end
137
-
138
- def allow_action(msg, context)
139
- name = context[:class_name]
140
- allow = name_allow_action(name)
141
- end
142
- end
143
-
144
-
145
- # filter on method
146
- class MethodFilter < BaseFilter
147
- def initialize(options)
148
- super(options)
149
- @rules = options[:method_rules] || options[:method_filter] || {}
150
- end
151
-
152
- def allow_action(msg, context)
153
- name = context[:method_name]
154
- @encountered ||= []
155
- name_allow_action(name)
156
- end
157
- end
158
-
159
- # filter on instance variables
160
- class InstanceVarFilter < BaseFilter
161
- attr_accessor :var_name
162
-
163
- def initialize(options)
164
- super(options)
165
- @rules = options[:var_rules] || {}
166
- var_name = options[:var_name]
167
- end
168
-
169
- def allow_action(msg, context)
170
- obj = context[:self]
171
- if var_name.kind_of?(Symbol) || var_name.kind_of?(String)
172
- value = obj.instance_variable_get(var_name)
173
- return name_allow_action(value)
174
- end
175
- :yield
176
- end
177
- end
178
- end
@@ -1,71 +0,0 @@
1
- module Tracing
2
- class CompositeClassFilter < BaseFilter
3
- def initialize(options)
4
- super(options)
5
- @rules = options || {}
6
- end
7
-
8
- # filter on class names and then methods within those classes
9
- def allow?(msg, context)
10
- # class name of context
11
- class_name = context[:class_name]
12
- rules[:classes].each do |clazz|
13
- names=clazz[:names]
14
- next if !names.matches_any?(name)
15
- # if name matches rule
16
- method_filter = MethodFilter.new(clazz)
17
- return false if !method_filter.allow?(msg, context)
18
- end
19
- return true
20
- end
21
- end
22
-
23
- class CompositeModuleFilter < BaseFilter
24
- def initialize(options)
25
- super(options)
26
- @rules = options || {}
27
- end
28
-
29
- # filter on module names and then on class names and methods within those modules
30
- def allow?(msg, context)
31
- modules_name = context[:full_module_name]
32
- rules[:modules].each do |_module|
33
- # get names of modules to match
34
- names = _module[:names]
35
- # test if current module name matches any of the module names for this rule
36
- next if !names.matches_any?(modules_name)
37
- # if name matches rule
38
- if _module[:classes]
39
- composite_class_filter = CompositeClassFilter.new(_module)
40
- return false if !composite_class_filter.allow?(msg, context)
41
- end
42
- if _module[:class_rules]
43
- class_filter = ClassFilter.new(_module)
44
- return false if !class_filter.allow?(msg, context)
45
- end
46
- if _module[:method_rules]
47
- method_filter = MethodFilter.new(_module)
48
- return false if !method_filter.allow?(msg, context)
49
- end
50
- end
51
- # log it!
52
- true
53
- end
54
- end
55
-
56
- class CompositeInstanceVarFilter < BaseFilter
57
- def initialize(options)
58
- super(options)
59
- @rules = options || {}
60
- end
61
-
62
- def allow?(msg, context)
63
- rules[:vars].each do |var|
64
- var_filter = InstanceVarFilter.new(var)
65
- return false if !var_filter.allow?(msg, context)
66
- end
67
- true
68
- end
69
- end
70
-
71
- end
@@ -1,5 +0,0 @@
1
- require 'erb'
2
- require 'templates/base_template'
3
- require 'templates/string_template'
4
- require 'templates/html_template'
5
- require 'templates/xml_template'
@@ -1,97 +0,0 @@
1
- # my_instance_variables = {:template_path => 'taglibs/rapid_core.dryml'}
2
- # args = {:a => 7}
3
- # context = {
4
- # :modules => cls_name.modules,
5
- # :class_name => cls_name.class_name,
6
- # :full_class_name => cls_name,
7
- # :method_name => name,
8
- # :args => args,
9
- # :block => false,
10
- # :vars => my_instance_variables # to carry @template_path etc.
11
- # }
12
-
13
- Module_filter_A = {
14
- :name => 'my modules',
15
- :module_rules => [{
16
- # id of modules rule set
17
- :name => ['my_modules'],
18
- :include => [/Al/],
19
- :exclude => [/Be/],
20
- :default => true
21
- }
22
- ]}
23
-
24
- Class_filter_A = {
25
- :name => 'my classes',
26
- :class_rules => [{
27
- # id of class rule set
28
- :name => 'my_classes',
29
- :include => [/MyCl/],
30
- :exclude => [/NotMy/],
31
- :include_and_yield => ['blap'],
32
- :default => false
33
- }]
34
- }
35
-
36
- Method_filter_A = {
37
- :name => 'my methods',
38
- :method_rules => [{
39
- # id of method rule set
40
- :name => 'my_methods',
41
- :include => [/by.*/, 'compile', 'do_it'],
42
- :exclude => ['my.*'],
43
- :exclude_and_yield => ['blip'],
44
- :default => false
45
- }]
46
- }
47
-
48
- Class_composite_filter_A = {
49
- # id of composite rule set
50
- :name => 'Template stuff',
51
- :classes => [{
52
- :names => ['My', /My/],
53
- :method_rules => {
54
- :include => [/by.*/, 'DRYMLBuilder'],
55
- :exclude => ['Taglib'],
56
- :default => false
57
- }
58
- }]
59
- }
60
-
61
- Module_composite_filter_A = {
62
- # id of composite rule set
63
- :name => 'dryml_filter',
64
- :modules => [{
65
- :names => ['Hobo:Dryml', /Dryml/],
66
- :class_rules => {
67
- :include => [/Template.*/, 'DRYMLBuilder'],
68
- :exclude => ['Taglib'],
69
- :default => true
70
- },
71
- :method_rules => {
72
- :include => [/Template.*/, 'DRYMLBuilder'],
73
- :exclude => ['Taglib'],
74
- :default => true
75
- }
76
- }]
77
- }
78
-
79
-
80
- # for specific instance_vars, match on values (after .to_s on var)
81
- Var_composite_filter_A = {
82
- :name => 'template_path',
83
- :vars => [{
84
- :name => 'template_path', :type => :string,
85
- :var_rules => {
86
- :include => [/.*\/taglib\/.*/],
87
- :exclude => [/.*\/rapid_.*/]
88
- }
89
- },
90
- {
91
- :name => 'template_path',
92
- :var_rules => {
93
- :exclude => [/.*\/rapid_.*/],
94
- :default => true
95
- }
96
- }]
97
- }
@@ -1,9 +0,0 @@
1
- require 'appenders/appender_registration'
2
- require 'appenders/appender'
3
- require 'appenders/base_appender'
4
- require 'appenders/file_appender'
5
- require 'appenders/logger_appender'
6
- require 'appenders/stream_appender'
7
- require 'appenders/xml_appender'
8
- require 'appenders/html_appender'
9
- require 'appenders/template_log_appender'
data/lib/trace_filters.rb DELETED
@@ -1,4 +0,0 @@
1
- require 'filters/tracing_filter'
2
- require 'filters/base_filters'
3
- require 'filters/composite_filters'
4
- require 'filters/filter_factory'
@@ -1,29 +0,0 @@
1
- require "core_extensions"
2
- require "trace_calls"
3
- require "sample_filters"
4
- require "rubygems"
5
- require "duration"
6
- require "test/unit"
7
-
8
- class TestFilter < Test::Unit::TestCase
9
-
10
- attr_reader :ah1, :filters
11
-
12
- def setup
13
- # Tracing::Appender.register_default_mappings
14
-
15
- # test all the ways an appender can be initialized!
16
- @ah1 = Tracing::LoggerAppender.new(:tracer => :html)
17
- end
18
-
19
- def teardown
20
- ## Nothing really
21
- end
22
-
23
- def test_filter
24
- puts @ah1.inspect
25
- end
26
-
27
-
28
- end
29
-
@@ -1,32 +0,0 @@
1
- require "core_extensions"
2
- require "trace_calls"
3
- require "sample_filters"
4
- require "rubygems"
5
- require "duration"
6
- require "test/unit"
7
-
8
- class TestFilter < Test::Unit::TestCase
9
-
10
- attr_reader :ah1, :filters
11
-
12
- def setup
13
- # Tracing::Appender.register_default_mappings
14
- @file = 'test.txt'
15
-
16
- # test all the ways an appender can be initialized!
17
- @file_appender = Tracing::FileAppender.new({:overwrite => true, :to_file => @file})
18
- end
19
-
20
- def teardown
21
- ## Nothing really
22
- end
23
-
24
- def test_filter
25
- @file_appender.write_file(@file, "Hello World")
26
- marker_txt = 'World'
27
- @file_appender.insert_into_file(@file, 'My old ', marker_txt)
28
- end
29
-
30
-
31
- end
32
-
data/test/test_filters.rb DELETED
@@ -1,112 +0,0 @@
1
- require "core_extensions"
2
- require "trace_calls"
3
- require "output_templates"
4
- require "sample_filters"
5
- require "rubygems"
6
- require "duration"
7
- require "test/unit"
8
-
9
- # configure use of TraceExt
10
- module Me
11
- class My
12
-
13
- def hello
14
- puts "Hello cruel World!"
15
- end
16
-
17
- def hi_there
18
- puts "Hello cruel World!"
19
- end
20
-
21
- def blip
22
- puts "Blip!"
23
- end
24
-
25
- def blap
26
- puts "Blap!"
27
- end
28
-
29
- end
30
- end
31
-
32
- Method_filter_hello = {
33
- :name => 'my methods',
34
- :method_rules => [{
35
- # id of method rule set
36
- :name => 'my_methods',
37
- :include => [/hi.*/, 'blip', 'blap'],
38
- :exclude => ['hello'],
39
- :default => false
40
- }]
41
- }
42
-
43
-
44
- class TestFilter < Test::Unit::TestCase
45
-
46
- attr_reader :ah1, :filters
47
-
48
- def setup
49
- # module filter is created (see sample filters)
50
- # @module_filter = Tracing::ModuleFilter.new(Module_filter_A)
51
-
52
- # Appender is configured with some appender options and a Tracer
53
- # string_tracer = Tracing::OutputTemplate::StringTrace.new
54
- # template_log_options = {:options => {:overwrite => false, :time_limit => 2.minutes}, :tracer => string_tracer}
55
- # tla1 = Tracing::TemplateLogAppender.new(:options => {:overwrite => false, :time_limit => 2.minutes}, :tracer => :string)
56
-
57
- # action handler is configured with a set of filters and a set of appenders
58
- # the appenders are called in turn if log statement passes all filters!
59
- @ah1 = Tracing::ActionHandler.new(:filters => @filters = [Module_filter_A, Method_filter_A], :appenders => :logger)
60
-
61
- appender_options = {:options => {:overwrite => false, :time_limit => 2.minutes}, :type => :logger, :tracer => :string}
62
-
63
- # @ah2 = Tracing::ActionHandler.new(:filters => @filters = [Module_filter_A, Method_filter_A], :appenders => appender_options)
64
-
65
- # TraceExt is configured with a set of action handlers
66
- # on any method call the set of action handlers are called if all initial filters are passed
67
- # Tracing::TraceExt.register_action_handlers([ah1])
68
- end
69
-
70
- def teardown
71
- ## Nothing really
72
- end
73
-
74
- def test_filter
75
- # module_filter = Tracing::ModuleFilter.new(Module_filter_A)
76
-
77
- # TraceExt can be configured with a set of 'initial' filters, that determine if the method should have theaspects applied at all
78
- # Tracing::TraceExt.register_filters([module_filter])
79
- # , :filters => Class_filter_A
80
- # Tracing::TraceExt.configure(:action_handlers => [ah1])
81
- # Tracing::TraceExt.configure(:appenders => :logger)
82
-
83
- dryml_classes_to_trace = [ 'My']
84
-
85
- dryml_classes_to_trace.each do |cls|
86
- str = "Me::#{cls}.class_eval { include Tracing::TraceCalls }"
87
- puts str
88
- eval str
89
- end
90
-
91
- # Me::My.class_eval { include Tracing::TraceCalls }
92
-
93
- Tracing::HtmlAppender.default_path = 'log_files/html'
94
-
95
- # Tracing::TraceExt.configure(:appenders => {:type => :html, :to_file => 'log_files/html/traced.html'})
96
- Tracing::TraceExt.configure(:type => :html, :to_file => 'traced4.html', :filters => Method_filter_hello)
97
-
98
- # Tracing::TraceExt.configure(:filters => Class_filter_A)
99
- #
100
- my = Me::My.new
101
- my.hello
102
- my.hi_there
103
- my.blip
104
- my.blap
105
-
106
-
107
- # my.action_handlers(['a', 'b'], context)
108
- end
109
-
110
-
111
- end
112
-
@@ -1,28 +0,0 @@
1
- require "core_extensions"
2
- require "trace_calls"
3
- require "output_templates"
4
- require "rubygems"
5
- require "duration"
6
- require "test/unit"
7
-
8
- class TestFilter < Test::Unit::TestCase
9
-
10
- def teardown
11
- ## Nothing really
12
- end
13
-
14
- def test_filter_create
15
-
16
- names = %w{blip blop}
17
- puts "create include method filter, names: #{names}"
18
- method_filter_B = Tracing::Filter.create_filter({:imethod_filter => names})
19
-
20
- f = Tracing::BaseFilter.create_filter(method_filter_B)
21
-
22
- puts method_filter_B.inspect
23
- puts f.inspect
24
- end
25
-
26
-
27
- end
28
-