filum 2.1.0 → 2.2.0

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: 0c43cbb4c0a3529ad8e0e1b4ec868fc3927795ce
4
- data.tar.gz: 02b286c120a26e3622a3c02b138db17cc86ed0ed
3
+ metadata.gz: 459d6d6c2a0166983cf1707a738d968373456ecd
4
+ data.tar.gz: 1326a77462239e8e5c3c6a38376ffdcf1eece67e
5
5
  SHA512:
6
- metadata.gz: a54fc4bc7dbdde39c63f832d9e0e4c2ca2a3f01dba257b7859ea0ccfd137749d15725492424b1628a369b2dc3bc182fe7ab609e145c06756777652fcf7518ec0
7
- data.tar.gz: 12a0b5c4a8f065d642c27cf84255012e07452796ea22b9ace2ecd9cba14862867629cea82a7d7d7e536588728a3b8b92247c9f31c455ceb52bb5cc64ba45b4b2
6
+ metadata.gz: 7ffbb1f37628c478232e770f1e2b21269fd8bcc26896121026acc6e54dcd96d932b93a651533ebccec272de8ccfb4ce72097457eca8f0fa2cdbd220bb2dc2b1d
7
+ data.tar.gz: 5bd4570a34232d4f3b50f0bf22e4548e6fc30fe86bb788ab45657bbeaedad01c56c7a1b4f407a3a52a319ecc4be7c586cba544bad9143a6bd126046b5e2a8bbd
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
+ .idea
6
7
  Gemfile.lock
7
8
  InstalledFiles
8
9
  _yardoc
@@ -1,3 +1,6 @@
1
+ 2.2.0 / 2014-10-07
2
+ [FEATURE] Log timings using start_ and end_
3
+
1
4
  2.1.0 / 2014-07-12
2
5
  [FEATURE] Allow STDOUT as logging options
3
6
 
@@ -3,8 +3,11 @@ require 'logger'
3
3
  module Filum
4
4
  class Logger < ::Logger
5
5
 
6
+
6
7
  attr_reader :logfile
8
+
7
9
  def initialize(logfile, options = {})
10
+ @timings = {}
8
11
  @logfile = logfile
9
12
  create_log_directory
10
13
 
@@ -17,6 +20,20 @@ module Filum
17
20
  Thread.current[:context_id] = context_id
18
21
  end
19
22
 
23
+ def start_timing(label)
24
+ @timings[label] = Time.now
25
+ info("Started timing for #{label} at #{@timings[label]}")
26
+ end
27
+
28
+ def end_timing(label)
29
+ finish = Time.now
30
+ if @timings[label]
31
+ info("Stopped timing for #{label} at #{@timings[label]}, #{(finish.to_f - @timings[label].to_f).round(3)}")
32
+ else
33
+ info("Stopped timing for #{label} at #{@timings[label]}, no start time found")
34
+ end
35
+ end
36
+
20
37
  private
21
38
  def create_log_directory
22
39
  return unless @logfile.is_a?(String)
@@ -1,3 +1,3 @@
1
1
  module Filum
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -46,5 +46,15 @@ module Filum
46
46
  Filum.logger.info "Foobar"
47
47
  assert_logged(/#{expected_file}:#{expected_line}/)
48
48
  end
49
+
50
+ def test_log_timings
51
+ expected_file = 'integration_test_...'
52
+ Filum.logger.start_timing 'Foo'
53
+ Filum.logger.end_timing 'Foo'
54
+
55
+ assert_logged(/Started timing for Foo/)
56
+ assert_logged(/Stopped timing for Foo/)
57
+ end
58
+
49
59
  end
50
60
  end
@@ -12,7 +12,8 @@ module Filum
12
12
  end
13
13
 
14
14
  def assert_logged(regex)
15
- assert File.readlines(Filum.logger.logfile).grep(regex).size == 1
15
+ lines = File.readlines(Filum.logger.logfile)
16
+ assert lines.grep(regex).size == 1, "Pattern (#{regex}) was not found in \n#{lines.join}"
16
17
  end
17
18
  end
18
19
  end
@@ -24,7 +24,7 @@ module Filum
24
24
  end
25
25
 
26
26
  def assert_logged(regex)
27
- assert File.readlines(@filename).grep(regex).size == 1
27
+ assert File.readlines(@filename).grep(regex).size == 1, "Pattern (#{regex}) was not found"
28
28
  end
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filum
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - MalcyL
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-12 00:00:00.000000000 Z
11
+ date: 2014-10-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.3'
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.3'
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: mocha
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
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yard
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: minitest
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 5.0.8
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 5.0.8
83
83
  description: Logging framework storing context id in thread local
@@ -87,7 +87,7 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
90
+ - ".gitignore"
91
91
  - CHANGELOG.md
92
92
  - Gemfile
93
93
  - LICENSE.md
@@ -116,17 +116,17 @@ require_paths:
116
116
  - lib
117
117
  required_ruby_version: !ruby/object:Gem::Requirement
118
118
  requirements:
119
- - - '>='
119
+ - - ">="
120
120
  - !ruby/object:Gem::Version
121
121
  version: '0'
122
122
  required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
- - - '>='
124
+ - - ">="
125
125
  - !ruby/object:Gem::Version
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 2.1.9
129
+ rubygems_version: 2.2.2
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: Identifies the context of log lines using a context id stored in Thread local