filum 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 426959005772065dfb25532dc64f4e9a947ac84b
4
- data.tar.gz: 54089585bc896384ad9125ac370073433e842f5e
3
+ metadata.gz: 0c43cbb4c0a3529ad8e0e1b4ec868fc3927795ce
4
+ data.tar.gz: 02b286c120a26e3622a3c02b138db17cc86ed0ed
5
5
  SHA512:
6
- metadata.gz: ba784e9ac29471e59f74186630f125042abb96a85d6bba4af164bc5953f5fec245ccf084fd3b39d8ce9ba9074f811dd22d153761c019507ca737b24b4760d7d1
7
- data.tar.gz: e79a649b039a704ed1fc6cb7884c089c750a1d5908754d6544bfed40cb724744b8b36ffe820b552b4a78b1599a56cbc4c2f33ce79c59f34120669ae7fa334242
6
+ metadata.gz: a54fc4bc7dbdde39c63f832d9e0e4c2ca2a3f01dba257b7859ea0ccfd137749d15725492424b1628a369b2dc3bc182fe7ab609e145c06756777652fcf7518ec0
7
+ data.tar.gz: 12a0b5c4a8f065d642c27cf84255012e07452796ea22b9ace2ecd9cba14862867629cea82a7d7d7e536588728a3b8b92247c9f31c455ceb52bb5cc64ba45b4b2
@@ -1,3 +1,6 @@
1
+ 2.1.0 / 2014-07-12
2
+ [FEATURE] Allow STDOUT as logging options
3
+
1
4
  2.0.0 / 2014-02-22
2
5
  [FEATURE] Remove config and add Filum.setup
3
6
 
@@ -19,6 +19,7 @@ module Filum
19
19
 
20
20
  private
21
21
  def create_log_directory
22
+ return unless @logfile.is_a?(String)
22
23
  dir = File.dirname(@logfile)
23
24
  unless File.directory?(dir)
24
25
  FileUtils.mkdir_p(dir)
@@ -1,3 +1,3 @@
1
1
  module Filum
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -0,0 +1,50 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Filum
4
+
5
+ class Worker
6
+ def self.process
7
+ Filum.logger.info "Processing"
8
+ end
9
+ end
10
+
11
+ module IntegrationTestBase
12
+
13
+ def test_one_logline
14
+ test_thread = Thread.new do
15
+ Filum.logger.context_id = "123456"
16
+ Worker.process
17
+ end
18
+ test_thread.join
19
+ assert_logged(/\[123456\]/)
20
+ end
21
+
22
+ def test_multiple_threads
23
+ test_thread1 = Thread.new do
24
+ Filum.logger.context_id = "23456a"
25
+ Worker.process
26
+ end
27
+ test_thread2 = Thread.new do
28
+ Filum.logger.context_id = "34567a"
29
+ Worker.process
30
+ end
31
+ test_thread1.join
32
+ test_thread2.join
33
+ assert_logged(/\[23456a\]/)
34
+ assert_logged(/\[34567a\]/)
35
+ end
36
+
37
+ def test_info_string_is_correct
38
+ random_string = [*'a'..'z'].sample(10).join
39
+ Filum.logger.info "Foobar #{random_string}"
40
+ assert_logged(/Foobar #{random_string}$/)
41
+ end
42
+
43
+ def test_caller_line_is_correct
44
+ expected_file = 'integration_test_...'
45
+ expected_line = __LINE__+1
46
+ Filum.logger.info "Foobar"
47
+ assert_logged(/#{expected_file}:#{expected_line}/)
48
+ end
49
+ end
50
+ end
@@ -1,52 +1,16 @@
1
- require File.expand_path('../../test_helper', __FILE__)
1
+ require_relative 'integration_test_base'
2
2
 
3
3
  module Filum
4
4
 
5
- class Worker
6
- def self.process
7
- Filum.logger.info "Processing"
8
- end
9
- end
10
-
11
- class LoggerTest < IntegrationTest
12
- def test_one_logline
13
- test_thread = Thread.new do
14
- Filum.logger.context_id = "123456"
15
- Worker.process
16
- end
17
- test_thread.join
18
- assert_logged(/\[123456\]/)
19
- end
20
-
21
- def test_multiple_threads
22
- test_thread1 = Thread.new do
23
- Filum.logger.context_id = "23456a"
24
- Worker.process
25
- end
26
- test_thread2 = Thread.new do
27
- Filum.logger.context_id = "34567a"
28
- Worker.process
29
- end
30
- test_thread1.join
31
- test_thread2.join
32
- assert_logged(/\[23456a\]/)
33
- assert_logged(/\[34567a\]/)
34
- end
35
-
36
- def test_info_string_is_correct
37
- random_string = [*'a'..'z'].sample(10).join
38
- Filum.logger.info "Foobar #{random_string}"
39
- assert_logged(/Foobar #{random_string}$/)
40
- end
5
+ class LoggerTest < Minitest::Test
6
+ include IntegrationTestBase
7
+ protected
41
8
 
42
- def test_caller_line_is_correct
43
- expected_file = 'logger_test.rb'
44
- expected_line = __LINE__+1
45
- Filum.logger.info "Foobar"
46
- assert_logged(/#{expected_file}:#{expected_line}/)
9
+ def setup
10
+ super
11
+ Filum.setup("/tmp/log/filum_test_#{Time.now.to_i}.log")
47
12
  end
48
13
 
49
- private
50
14
  def assert_logged(regex)
51
15
  assert File.readlines(Filum.logger.logfile).grep(regex).size == 1
52
16
  end
@@ -0,0 +1,31 @@
1
+ require_relative 'integration_test_base'
2
+
3
+ module Filum
4
+
5
+ class StdOutLoggerTest < Minitest::Test
6
+ include IntegrationTestBase
7
+
8
+ def setup
9
+ super
10
+
11
+ @filename = "/tmp/log/filum_stdout_test_#{Time.now.to_i}.log"
12
+ $stdout.expects(:write).at_least_once.with do |data|
13
+ File.open(@filename, "a") do |file|
14
+ file.write(data)
15
+ end
16
+ end
17
+
18
+ Filum.setup($stdout)
19
+ end
20
+
21
+ def teardown
22
+ super
23
+ mocha_teardown
24
+ end
25
+
26
+ def assert_logged(regex)
27
+ assert File.readlines(@filename).grep(regex).size == 1
28
+ end
29
+ end
30
+ end
31
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filum
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.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-02-23 00:00:00.000000000 Z
11
+ date: 2014-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -99,8 +99,9 @@ files:
99
99
  - lib/filum/log_formatter.rb
100
100
  - lib/filum/logger.rb
101
101
  - lib/filum/version.rb
102
- - test/integration/integration_test.rb
102
+ - test/integration/integration_test_base.rb
103
103
  - test/integration/logger_test.rb
104
+ - test/integration/stdout_logger_test.rb
104
105
  - test/test_helper.rb
105
106
  - test/unit/filum_test.rb
106
107
  - test/unit/log_formatter_test.rb
@@ -130,8 +131,9 @@ signing_key:
130
131
  specification_version: 4
131
132
  summary: Identifies the context of log lines using a context id stored in Thread local
132
133
  test_files:
133
- - test/integration/integration_test.rb
134
+ - test/integration/integration_test_base.rb
134
135
  - test/integration/logger_test.rb
136
+ - test/integration/stdout_logger_test.rb
135
137
  - test/test_helper.rb
136
138
  - test/unit/filum_test.rb
137
139
  - test/unit/log_formatter_test.rb
@@ -1,11 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
-
3
- module Filum
4
-
5
- class IntegrationTest < Minitest::Test
6
- def setup
7
- super
8
- Filum.setup("/tmp/log/filum_test_#{Time.now.to_i}.log")
9
- end
10
- end
11
- end