semantic_logger 4.0.0.rc1 → 4.0.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: ab29b9707e87eb2a509437de9450080a5fbe7938
4
- data.tar.gz: 893e64efec814a11175c306b5edd0bcf07c85a9f
3
+ metadata.gz: b013a6597ef91c2f2b5da17fad3081736d000ae4
4
+ data.tar.gz: 8893e45e15e2ff4c6c397b5892c63d72acdc7faf
5
5
  SHA512:
6
- metadata.gz: a34b4144be7c09e17f017e4bca5c8f8d7ea690ca738bac8f1e09552b16f5fd019d420f55322422490569a4e7f80cbc4c83315866619d2d5ffcc00dfcbf578120
7
- data.tar.gz: 46785f3003aa0e1e99174ccfffbc7eae5ef8882ba8ab22d1ffba98641211371f6a2b2e3d83175d1f4080b9179d6a3a0e27b3b4ed58c33be546241b46fd270c4a
6
+ metadata.gz: 365fe77c43d97fe8923a299bde0113095853b0083610dea1df76977e68d095c673eb393ac79c3baf659d8ddb150ba6f091a92aa4b2325cde936026a7102a6eff
7
+ data.tar.gz: bddea8b37c3d837690b56c5734ba22d05e47877f4aaf0a830545a8e3156f0a3170c2fe3953df483d5a31044b394978d9f50f652e1aea8d955f2e69152379082c
@@ -100,11 +100,14 @@ class SemanticLogger::Appender::Graylog < SemanticLogger::Subscriber
100
100
  def call(log, logger)
101
101
  h = log.to_h(host, application)
102
102
  h.delete(:time)
103
+ h.delete(:message) if log.message
104
+
105
+ short_message = log.message || log.exception.message
103
106
  h[:timestamp] = log.time.utc.to_f
104
107
  h[:level] = logger.map_level(log)
105
108
  h[:level_str] = log.level.to_s
106
109
  h[:duration_str] = h.delete(:duration)
107
- h[:short_message] = h.delete(:message) if log.message
110
+ h[:short_message] = short_message
108
111
  h
109
112
  end
110
113
 
@@ -18,8 +18,14 @@ module SemanticLogger
18
18
  # Must be one of the values in SemanticLogger::LEVELS, or
19
19
  # nil if this logger instance should use the global default level
20
20
  def level=(level)
21
- @level_index = SemanticLogger.level_to_index(level)
22
- @level = SemanticLogger.send(:index_to_level, @level_index)
21
+ if level.nil?
22
+ # Use the global default level for this logger
23
+ @level_index = nil
24
+ @level = nil
25
+ else
26
+ @level_index = SemanticLogger.level_to_index(level)
27
+ @level = SemanticLogger.send(:index_to_level, @level_index)
28
+ end
23
29
  end
24
30
 
25
31
  # Returns the current log level if set, otherwise it returns the global
@@ -37,7 +37,7 @@ module SemanticLogger
37
37
 
38
38
  # Named Tags
39
39
  if (named_tags = log.named_tags) && !named_tags.empty?
40
- list = {}
40
+ list = []
41
41
  named_tags.each_pair { |name, value| list << "[#{level_color}#{name}: #{value}#{colors::CLEAR}]" }
42
42
  message << ' ' << list.join(' ')
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module SemanticLogger #:nodoc
2
- VERSION = '4.0.0.rc1'
2
+ VERSION = '4.0.0'
3
3
  end
@@ -30,9 +30,27 @@ module Appender
30
30
  @appender.notifier.stub(:notify!, -> h { hash = h }) do
31
31
  @appender.error 'Reading File', exc
32
32
  end
33
- assert 'Reading File', hash[:short_message]
34
- assert 'NameError', hash[:exception][:name]
35
- assert 'undefined local variable or method', hash[:exception][:message]
33
+ assert_equal 'Reading File', hash[:short_message]
34
+ assert_equal 'NameError', hash[:exception][:name]
35
+ assert_match 'undefined local variable or method', hash[:exception][:message]
36
+ assert_equal 3, hash[:level], 'Should be error level (3)'
37
+ assert hash[:exception][:stack_trace].first.include?(__FILE__), hash[:exception]
38
+ end
39
+
40
+ it 'send exception notifications to Graylog without log message' do
41
+ hash = nil
42
+ exc = nil
43
+ begin
44
+ raise StandardError, 'Reading File'
45
+ rescue Exception => e
46
+ exc = e
47
+ end
48
+ @appender.notifier.stub(:notify!, -> h { hash = h }) do
49
+ @appender.error exc
50
+ end
51
+ assert_equal exc.message, hash[:short_message]
52
+ assert_equal exc.class.to_s, hash[:exception][:name]
53
+ assert_match exc.message, hash[:exception][:message]
36
54
  assert_equal 3, hash[:level], 'Should be error level (3)'
37
55
  assert hash[:exception][:stack_trace].first.include?(__FILE__), hash[:exception]
38
56
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: semantic_logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.rc1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Reid Morrison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -113,9 +113,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
113
  version: '2.1'
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - ">"
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: 1.3.1
118
+ version: '0'
119
119
  requirements: []
120
120
  rubyforge_project:
121
121
  rubygems_version: 2.6.8