teelogger 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 374fbb37a9d2c70a80c83f6c52ec70501fef456a
4
- data.tar.gz: 43ff68bc53641a1805f21e76916ec5241b0e5549
3
+ metadata.gz: 33bd79b4386cd699bb1293011cd5982edee2458d
4
+ data.tar.gz: 28df88866d33f0678d4ee964c68e8ffbd603d9c0
5
5
  SHA512:
6
- metadata.gz: 704c17de207b1a44bb1886ea9291c27c77c67b8e38140dcca144f21009705dae5e58c50a8ce056e877195320be3413985915d2d96651a7e691042846126ad0b8
7
- data.tar.gz: 0797bc600ca9c252c61ec27289cc61103143ab7df846760b025f0039f5222d98aa0fd13db267fd6042053fc614bcad71e7e2bb005e97ea50f8a198d5f663bd2e
6
+ metadata.gz: 8e8ba78dcc4e630caa5c735f2a00552224289171af9bcf6db61aad02a7023a336db52279d040f608ccbca4edb150be736f4bbd4c5e20d7106bd30142ba813c26
7
+ data.tar.gz: 4f0b65a534c59edbc76a14d925c274d1733c5ce84ea88bd5415b22361e438795ace05a1f8625dcf27268138095093e65c04aad722864223a59e01f1812673b68
@@ -12,9 +12,6 @@ rvm:
12
12
  - 2.1.0
13
13
  - 2.2.2
14
14
  - jruby
15
- matrix:
16
- allow_failures:
17
- rvm: 2.2.2
18
15
  env:
19
16
  CODECLIMATE_REPO_TOKEN=e37a93224a40c36fd6a24465c063e7627661921a868a2d1321ad2937d7889de6
20
17
  notifications:
@@ -0,0 +1,11 @@
1
+ @issues
2
+ Feature: Issues
3
+ As a user of the teelogger gem
4
+ When I file an issue
5
+ I expect a regression test from it
6
+
7
+ @issue_7
8
+ Scenario: Complex data causes exception in filter
9
+ Given I create a TeeLogger for regression testing issues
10
+ And I log complex data
11
+ Then I expect there not to be an exception
@@ -17,7 +17,7 @@ Given(/^I call it with parameters "([^"]*)", "([^"]*)", "([^"]*)" and "([^"]*)"$
17
17
  # machines.
18
18
  zone = ENV["TZ"]
19
19
  ENV["TZ"] = "UTC"
20
- t = Time.parse(time)
20
+ t = Time.parse(time).localtime
21
21
  ENV["TZ"] = zone
22
22
 
23
23
  result = formatter.call(severity, t, progname, message)
@@ -0,0 +1,36 @@
1
+ io = nil
2
+ logger = nil
3
+ error = nil
4
+
5
+ Given(/^I create a TeeLogger for regression testing issues$/) do
6
+ io = StringIO.new
7
+ logger = TeeLogger::TeeLogger.new io
8
+ assert [TeeLogger::DEFAULT_FLUSH_INTERVAL] == logger.flush_interval, "Flush interval is not default: #{logger.flush_interval}"
9
+ end
10
+
11
+ Given(/^I log complex data$/) do
12
+ # Reduced data from issue #7
13
+ data = {
14
+ "status" => 200,
15
+ "result" => {
16
+ "id" => 123,
17
+ "caps" => [
18
+ {
19
+ "first" => [42],
20
+ "second" => ["some string"],
21
+ },
22
+ ],
23
+ },
24
+ }
25
+
26
+ begin
27
+ logger.error(data)
28
+ error = nil
29
+ rescue StandardError => err
30
+ error = err
31
+ end
32
+ end
33
+
34
+ Then(/^I expect there not to be an exception$/) do
35
+ assert error.nil?, "Expected no error, but got: #{error}"
36
+ end
@@ -1,10 +1,11 @@
1
1
  require "codeclimate-test-reporter"
2
2
  CodeClimate::TestReporter.start
3
3
 
4
- begin
5
- require 'test/unit/assertions'
6
- rescue LoadError
7
- require 'minitest/assertions'
4
+ # Simple assert function
5
+ def assert(condition, message = "Unknown reason")
6
+ if not condition
7
+ raise message
8
+ end
8
9
  end
9
10
 
10
11
  require "teelogger"
@@ -226,7 +226,6 @@ public
226
226
  end
227
227
 
228
228
  def method_missing(meth, *args, &block)
229
- puts "MISSING #{meth}"
230
229
  dispatch(meth, *args, &block)
231
230
  end
232
231
 
@@ -20,6 +20,10 @@ module TeeLogger
20
20
  /salt[a-z\-_]*/,
21
21
  ]
22
22
 
23
+ ##
24
+ # Word to use in place of original values
25
+ REDACTED_WORD = "[REDACTED]"
26
+
23
27
  ##
24
28
  # Filter words
25
29
  def filter_words
@@ -31,7 +31,7 @@ module TeeLogger
31
31
  args.each do |arg|
32
32
  @matches.each do |match|
33
33
  # Modify the matching arguments in place
34
- arg.gsub!(match, '\1[REDACTED]')
34
+ arg.gsub!(match, "\1#{::TeeLogger::Filter::REDACTED_WORD}")
35
35
  end
36
36
  end
37
37
 
@@ -35,7 +35,7 @@ module TeeLogger
35
35
  # Otherwise, if the first argument matches, we'll redact the second.
36
36
  @matches.each do |word|
37
37
  if word.match(args[0])
38
- args[1] = '[REDACTED]'
38
+ args[1] = ::TeeLogger::Filter::REDACTED_WORD
39
39
  end
40
40
  end
41
41
  return args
@@ -20,35 +20,42 @@ module TeeLogger
20
20
  # For each argument, recurse processing. Note that due to the window
21
21
  # size of one, args is only an element long - but let's write this out
22
22
  # properly.
23
+ processed_args = []
24
+
23
25
  args.each do |arg|
24
- # Since we're matching enumerabls, the argument must respond to .each
25
- arg.each do |expanded|
26
- # The expanded variable can be a single item or a list of items.
27
- # If expanded is itself an Enumarable, the first item is a key, the remainder
28
- # values. We need to recursively process the values.
29
- if expanded.is_a? Enumerable
30
- # If the key matches any of the filter words, we'll just skip
31
- # the value entirely.
32
- key = expanded[0]
26
+ # So we have an Enumerable, but we don't know whether it's Array-like
27
+ # or Hash-like. We'll check whether it responds to ".keys", and then
28
+ # treat it as a Hash.
29
+ processed = nil
30
+ if arg.respond_to? :keys
31
+ processed = {}
32
+ # Looks like a Hash, treat it like a Hash
33
+ arg.each do |key, value|
34
+
35
+ # If the key is a match, we'll just redact the entire value.
33
36
  redacted = false
34
37
  run_data[:words].each do |word|
35
38
  if word.match(key.to_s)
36
- arg[key] = '[REDACTED]'
37
- redacted = true
38
- break
39
+ processed[key] = ::TeeLogger::Filter::REDACTED_WORD
40
+ redacted = true
41
+ break
39
42
  end
40
43
  end
41
44
 
45
+ # Otherwise, pass it through
42
46
  if not redacted
43
- arg[key] = run_data[:filters].apply_filters_internal(run_data, *expanded[1..-1])
47
+ processed[key] = run_data[:filters].apply_filters_internal(run_data, value)[0]
44
48
  end
45
- else
46
- arg = run_data[:filters].apply_filters_internal(run_data, expanded)
47
49
  end
50
+ else
51
+ # Treat it like an Array
52
+ processed = run_data[:filters].apply_filters_internal(run_data, *arg)
48
53
  end
54
+
55
+ processed_args << processed
49
56
  end
50
57
 
51
- return args
58
+ return processed_args
52
59
  end
53
60
  end # class Recursive
54
61
  end # module Filter
@@ -6,5 +6,5 @@
6
6
  # All rights reserved.
7
7
  #
8
8
  module TeeLogger
9
- VERSION = "0.5.0"
9
+ VERSION = "0.5.1"
10
10
  end
@@ -19,9 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.6"
22
- spec.add_development_dependency "rake"
23
- spec.add_development_dependency "cucumber"
24
- spec.add_development_dependency "minitest"
22
+ spec.add_development_dependency "rake", "~> 0"
23
+ spec.add_development_dependency "cucumber", "~> 0"
25
24
 
26
25
  spec.add_dependency "tai64", "~> 0.0"
27
26
  spec.add_dependency "require_all", "~> 1.3"
metadata CHANGED
@@ -1,97 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teelogger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jens Finkhaeuser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: cucumber
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: minitest
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
52
+ - - "~>"
67
53
  - !ruby/object:Gem::Version
68
54
  version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: tai64
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
- - - ~>
59
+ - - "~>"
74
60
  - !ruby/object:Gem::Version
75
61
  version: '0.0'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - ~>
66
+ - - "~>"
81
67
  - !ruby/object:Gem::Version
82
68
  version: '0.0'
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: require_all
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ~>
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
75
  version: '1.3'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ~>
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
82
  version: '1.3'
97
83
  description: Mini wrapper around Ruby Logger for logging to multiple destinations.
@@ -101,17 +87,19 @@ executables: []
101
87
  extensions: []
102
88
  extra_rdoc_files: []
103
89
  files:
104
- - .gitignore
105
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".travis.yml"
106
92
  - Gemfile
107
93
  - LICENSE
108
94
  - README.md
109
95
  - Rakefile
110
96
  - features/filter.feature
111
97
  - features/formatter.feature
98
+ - features/issues.feature
112
99
  - features/logger.feature
113
100
  - features/step_definitions/filter_steps.rb
114
101
  - features/step_definitions/formatter_steps.rb
102
+ - features/step_definitions/issue_steps.rb
115
103
  - features/step_definitions/logger_steps.rb
116
104
  - features/support/env.rb
117
105
  - lib/teelogger.rb
@@ -134,25 +122,27 @@ require_paths:
134
122
  - lib
135
123
  required_ruby_version: !ruby/object:Gem::Requirement
136
124
  requirements:
137
- - - '>='
125
+ - - ">="
138
126
  - !ruby/object:Gem::Version
139
127
  version: '0'
140
128
  required_rubygems_version: !ruby/object:Gem::Requirement
141
129
  requirements:
142
- - - '>='
130
+ - - ">="
143
131
  - !ruby/object:Gem::Version
144
132
  version: '0'
145
133
  requirements: []
146
134
  rubyforge_project:
147
- rubygems_version: 2.0.3
135
+ rubygems_version: 2.2.3
148
136
  signing_key:
149
137
  specification_version: 4
150
138
  summary: Mini wrapper around Ruby Logger for logging to multiple destinations.
151
139
  test_files:
152
140
  - features/filter.feature
153
141
  - features/formatter.feature
142
+ - features/issues.feature
154
143
  - features/logger.feature
155
144
  - features/step_definitions/filter_steps.rb
156
145
  - features/step_definitions/formatter_steps.rb
146
+ - features/step_definitions/issue_steps.rb
157
147
  - features/step_definitions/logger_steps.rb
158
148
  - features/support/env.rb