semantic_logger 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.
@@ -1,3 +1,3 @@
1
1
  module SemanticLogger #:nodoc
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.0"
3
3
  end
@@ -21,15 +21,15 @@ class AppenderFileTest < Test::Unit::TestCase
21
21
  @time = Time.new
22
22
  @io = StringIO.new
23
23
  @appender = SemanticLogger::Appender::File.new(@io)
24
- SemanticLogger::Logger.default_level = :trace
25
- SemanticLogger::Logger.appenders << @appender
24
+ SemanticLogger.default_level = :trace
25
+ SemanticLogger.add_appender(@appender)
26
26
  @hash = { :session_id => 'HSSKLEU@JDK767', :tracking_number => 12345 }
27
27
  @hash_str = @hash.inspect.sub("{", "\\{").sub("}", "\\}")
28
28
  @thread_name = SemanticLogger::Base.thread_name
29
29
  end
30
30
 
31
31
  teardown do
32
- SemanticLogger::Logger.appenders.delete(@appender)
32
+ SemanticLogger.remove_appender(@appender)
33
33
  end
34
34
 
35
35
  context "for each log level" do
@@ -37,12 +37,12 @@ class AppenderFileTest < Test::Unit::TestCase
37
37
  SemanticLogger::LEVELS.each do |level|
38
38
  should "log #{level} information with class attribute" do
39
39
  TestAttribute.logger.send(level, "hello #{level}", @hash)
40
- SemanticLogger::Logger.flush
40
+ SemanticLogger.flush
41
41
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:#{@thread_name}\] TestAttribute -- hello #{level} -- #{@hash_str}\n/, @io.string
42
42
  end
43
43
  should "log #{level} information with instance attribute" do
44
44
  TestAttribute.new.logger.send(level, "hello #{level}", @hash)
45
- SemanticLogger::Logger.flush
45
+ SemanticLogger.flush
46
46
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:#{@thread_name}\] TestAttribute -- hello #{level} -- #{@hash_str}\n/, @io.string
47
47
  end
48
48
  end
data/test/logger_test.rb CHANGED
@@ -13,9 +13,9 @@ class LoggerTest < Test::Unit::TestCase
13
13
  setup do
14
14
  # Use a mock logger that just keeps the last logged entry in an instance
15
15
  # variable
16
+ SemanticLogger.default_level = :trace
16
17
  @mock_logger = MockLogger.new
17
- @appender = SemanticLogger::Appender::Wrapper.new(@mock_logger)
18
- SemanticLogger::Logger.appenders << @appender
18
+ SemanticLogger.add_appender(@mock_logger)
19
19
 
20
20
  # Use this test's class name as the application name in the log output
21
21
  @logger = SemanticLogger::Logger.new(self.class, :trace)
@@ -24,14 +24,15 @@ class LoggerTest < Test::Unit::TestCase
24
24
  end
25
25
 
26
26
  teardown do
27
- SemanticLogger::Logger.appenders.delete(@appender)
27
+ # Remove all appenders
28
+ SemanticLogger.appenders.each{|appender| SemanticLogger.remove_appender(appender)}
28
29
  end
29
30
 
30
31
  # Ensure that any log level can be logged
31
32
  SemanticLogger::LEVELS.each do |level|
32
33
  should "log #{level} info" do
33
34
  @logger.send(level, 'hello world', @hash) { "Calculations" }
34
- SemanticLogger::Logger.flush
35
+ SemanticLogger.flush
35
36
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- hello world -- Calculations -- #{@hash_str}/, @mock_logger.message
36
37
  end
37
38
  end
@@ -40,7 +41,7 @@ class LoggerTest < Test::Unit::TestCase
40
41
  should "add tags to log entries" do
41
42
  @logger.with_tags('12345', 'DJHSFK') do
42
43
  @logger.info('Hello world')
43
- SemanticLogger::Logger.flush
44
+ SemanticLogger.flush
44
45
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \[12345\] \[DJHSFK\] LoggerTest -- Hello world/, @mock_logger.message
45
46
  end
46
47
  end
@@ -49,7 +50,7 @@ class LoggerTest < Test::Unit::TestCase
49
50
  @logger.with_tags('First Level', 'tags') do
50
51
  @logger.with_tags('Second Level') do
51
52
  @logger.info('Hello world')
52
- SemanticLogger::Logger.flush
53
+ SemanticLogger.flush
53
54
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \[First Level\] \[tags\] \[Second Level\] LoggerTest -- Hello world/, @mock_logger.message
54
55
  end
55
56
  end
@@ -61,7 +62,7 @@ class LoggerTest < Test::Unit::TestCase
61
62
  @logger.with_payload(:tracking_number => '123456') do
62
63
  @logger.with_payload(:even => 2, :more => 'data') do
63
64
  @logger.info('Hello world')
64
- SemanticLogger::Logger.flush
65
+ SemanticLogger.flush
65
66
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] LoggerTest -- Hello world -- #{hash_str}/, @mock_logger.message
66
67
  end
67
68
  end
@@ -86,25 +87,25 @@ class LoggerTest < Test::Unit::TestCase
86
87
  SemanticLogger::LEVELS.each do |level|
87
88
  should "log #{level} info" do
88
89
  assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world') { "result" } # Measure duration of the supplied block
89
- SemanticLogger::Logger.flush
90
+ SemanticLogger.flush
90
91
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world/, @mock_logger.message
91
92
  end
92
93
 
93
94
  should "log #{level} info with payload" do
94
95
  assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world', :payload => @hash) { "result" } # Measure duration of the supplied block
95
- SemanticLogger::Logger.flush
96
+ SemanticLogger.flush
96
97
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
97
98
  end
98
99
 
99
100
  should "not log #{level} info when block is faster than :min_duration" do
100
101
  assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world', :min_duration => 0.5) { "result" } # Measure duration of the supplied block
101
- SemanticLogger::Logger.flush
102
+ SemanticLogger.flush
102
103
  assert_nil @mock_logger.message
103
104
  end
104
105
 
105
106
  should "log #{level} info when block duration exceeds :min_duration" do
106
107
  assert_equal "result", @logger.send("benchmark_#{level}".to_sym, 'hello world', :min_duration => 0.2, :payload => @hash) { sleep 0.5; "result" } # Measure duration of the supplied block
107
- SemanticLogger::Logger.flush
108
+ SemanticLogger.flush
108
109
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
109
110
  end
110
111
 
@@ -112,14 +113,14 @@ class LoggerTest < Test::Unit::TestCase
112
113
  assert_raise RuntimeError do
113
114
  @logger.send("benchmark_#{level}", 'hello world', :payload => @hash) { raise RuntimeError.new("Test") } # Measure duration of the supplied block
114
115
  end
115
- SemanticLogger::Logger.flush
116
+ SemanticLogger.flush
116
117
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- Exception: RuntimeError: Test -- #{@hash_str}/, @mock_logger.message
117
118
  end
118
119
  end
119
120
 
120
121
  should "log when the block performs a return" do
121
122
  assert_equal "Good", function_with_return(@logger)
122
- SemanticLogger::Logger.flush
123
+ SemanticLogger.flush
123
124
  assert_match /\d+-\d+-\d+ \d+:\d+:\d+.\d+ \w \[\d+:.+\] \(\d+\.\dms\) LoggerTest -- hello world -- #{@hash_str}/, @mock_logger.message
124
125
  end
125
126
  end
metadata CHANGED
@@ -1,64 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
5
- prerelease:
4
+ version: 2.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Reid Morrison
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-20 00:00:00.000000000 Z
11
+ date: 2013-04-03 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sync_attr
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '1.0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '1.0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: thread_safe
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: 0.1.0
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: shoulda
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
40
+ version: 0.1.0
62
41
  description: Semantic Logger takes logging in Ruby to a new level by adding several
63
42
  new capabilities to the commonly used Logging API
64
43
  email:
@@ -68,7 +47,10 @@ extensions: []
68
47
  extra_rdoc_files: []
69
48
  files:
70
49
  - Gemfile
71
- - Gemfile.lock
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/semantic_logger.rb
72
54
  - lib/semantic_logger/appender/base.rb
73
55
  - lib/semantic_logger/appender/file.rb
74
56
  - lib/semantic_logger/appender/mongodb.rb
@@ -76,17 +58,8 @@ files:
76
58
  - lib/semantic_logger/base.rb
77
59
  - lib/semantic_logger/loggable.rb
78
60
  - lib/semantic_logger/logger.rb
61
+ - lib/semantic_logger/semantic_logger.rb
79
62
  - lib/semantic_logger/version.rb
80
- - lib/semantic_logger.rb
81
- - LICENSE.txt
82
- - nbproject/private/config.properties
83
- - nbproject/private/private.properties
84
- - nbproject/private/private.xml
85
- - nbproject/private/rake-d.txt
86
- - nbproject/project.properties
87
- - nbproject/project.xml
88
- - Rakefile
89
- - README.md
90
63
  - test/appender_file_test.rb
91
64
  - test/appender_mongodb_test.rb
92
65
  - test/appender_wrapper_test.rb
@@ -94,30 +67,27 @@ files:
94
67
  - test/logger_test.rb
95
68
  - test/mock_logger.rb
96
69
  homepage: https://github.com/ClarityServices/semantic_logger
97
- licenses: []
70
+ licenses:
71
+ - Apache License V2.0
72
+ metadata: {}
98
73
  post_install_message:
99
74
  rdoc_options: []
100
75
  require_paths:
101
76
  - lib
102
77
  required_ruby_version: !ruby/object:Gem::Requirement
103
- none: false
104
78
  requirements:
105
- - - ! '>='
79
+ - - '>='
106
80
  - !ruby/object:Gem::Version
107
81
  version: '0'
108
- segments:
109
- - 0
110
- hash: -2743860428818841167
111
82
  required_rubygems_version: !ruby/object:Gem::Requirement
112
- none: false
113
83
  requirements:
114
- - - ! '>='
84
+ - - '>='
115
85
  - !ruby/object:Gem::Version
116
86
  version: '0'
117
87
  requirements: []
118
88
  rubyforge_project:
119
- rubygems_version: 1.8.24
89
+ rubygems_version: 2.0.2
120
90
  signing_key:
121
- specification_version: 3
91
+ specification_version: 4
122
92
  summary: Improved logging for Ruby
123
93
  test_files: []
data/Gemfile.lock DELETED
@@ -1,33 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- activesupport (3.2.8)
5
- i18n (~> 0.6)
6
- multi_json (~> 1.0)
7
- bson (1.7.0)
8
- bson (1.7.0-java)
9
- bson_ext (1.7.0)
10
- bson (~> 1.7.0)
11
- i18n (0.6.1)
12
- mongo (1.7.0)
13
- bson (~> 1.7.0)
14
- multi_json (1.3.6)
15
- shoulda (3.3.0)
16
- shoulda-context (~> 1.0)
17
- shoulda-matchers (~> 1.4)
18
- shoulda-context (1.0.0)
19
- shoulda-matchers (1.4.0)
20
- activesupport (>= 3.0.0)
21
- sync_attr (0.1.1)
22
- thread_safe (0.0.3)
23
-
24
- PLATFORMS
25
- java
26
- ruby
27
-
28
- DEPENDENCIES
29
- bson_ext
30
- mongo
31
- shoulda
32
- sync_attr
33
- thread_safe
File without changes
@@ -1 +0,0 @@
1
- platform.active=Ruby_0
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project-private xmlns="http://www.netbeans.org/ns/project-private/1">
3
- <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
4
- </project-private>
@@ -1,4 +0,0 @@
1
- clean=
2
- clobber=
3
- gem=
4
- test=
@@ -1,7 +0,0 @@
1
- javac.classpath=
2
- main.file=main.rb
3
- platform.active=JRuby
4
- source.encoding=UTF-8
5
- spec.src.dir=spec
6
- src.dir=lib
7
- test.src.dir=test
@@ -1,16 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project xmlns="http://www.netbeans.org/ns/project/1">
3
- <type>org.netbeans.modules.ruby.rubyproject</type>
4
- <configuration>
5
- <data xmlns="http://www.netbeans.org/ns/ruby-project/1">
6
- <name>semantic_logger</name>
7
- <source-roots>
8
- <root id="src.dir"/>
9
- </source-roots>
10
- <test-roots>
11
- <root id="test.src.dir"/>
12
- <root id="spec.src.dir"/>
13
- </test-roots>
14
- </data>
15
- </configuration>
16
- </project>