semantic_logger 4.0.0.beta1 → 4.0.0.beta2

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: 0753c0265adc4668e64539c5014d6ea98a9f5659
4
- data.tar.gz: 4af0ca018bd158bccc8506985c84f8e29dad6d1f
3
+ metadata.gz: 3066e966beb70e220a27c8f45043eba84ce0a339
4
+ data.tar.gz: '08a10fa0381149833d7c39b2ae1d8d07c0ea2e4b'
5
5
  SHA512:
6
- metadata.gz: eba4d620e6930c556912f8fc089326d3dbfca5bc8224e2949487509c70a37f332580ce96c78d06ae1249a15169930395a1697a012c687b2bbcf6aa58ce4d6138
7
- data.tar.gz: 0206b4fedff5b5850d9f8541588263643f8a21a7c732a3845a12c6f4f94272ddc2042a613159fe8030e9f3855740d7461dc10885b24cbf2bd8071ce613361651
6
+ metadata.gz: 4ff7e40427736b675133b525f8da512c138c62194bb0225a01054b119ca83ab7d1352d7c6323e9da4a2edf94cbe27c1e98906bb6734dd0c1bcfa11d744b99f51
7
+ data.tar.gz: d58d10c056b3a73b3f1023eb3e3ce6548ef03171fe391e162aae7ab9effede30bdc995e0bca2b9496bb10cf61e6427d1fca42d7d59b990dc6edc191abd3a1d0c
@@ -49,20 +49,21 @@ class SemanticLogger::Appender::Elasticsearch < SemanticLogger::Appender::Http
49
49
  @index = options.delete(:index) || 'semantic_logger'
50
50
  @type = options.delete(:type) || 'log'
51
51
  options[:url] ||= 'http://localhost:9200'
52
-
53
52
  super(options, &block)
53
+ @request_path = "#{@path.end_with?('/') ? @path : "#{@path}/"}#{@index}-%Y.%m.%d"
54
+ @logging_path = "#{@request_path}/#{type}"
54
55
  end
55
56
 
56
57
  # Log to the index for today
57
58
  def log(log)
58
59
  return false unless should_log?(log)
59
60
 
60
- post(formatter.call(log, self), "#{index}-#{log.time.strftime('%Y.%m.%d')}/#{type}")
61
+ post(formatter.call(log, self), log.time.strftime(@logging_path))
61
62
  end
62
63
 
63
64
  # Deletes all log data captured for a day
64
65
  def delete_all(date = Date.today)
65
- "#{index}-#{date.strftime('%Y.%m.%d')}/#{type}"
66
+ delete(date.strftime(@request_path))
66
67
  end
67
68
 
68
69
  end
@@ -103,6 +103,7 @@ class SemanticLogger::Appender::Graylog < SemanticLogger::Subscriber
103
103
  h[:timestamp] = log.time.utc.to_f
104
104
  h[:level] = logger.map_level(log)
105
105
  h[:level_str] = log.level.to_s
106
+ h[:duration_str] = h.delete(:duration)
106
107
  h[:short_message] = h.delete(:message) if log.message
107
108
  h
108
109
  end
@@ -101,12 +101,14 @@ class SemanticLogger::Appender::Http < SemanticLogger::Subscriber
101
101
 
102
102
  uri = URI.parse(@url)
103
103
  @server = uri.host
104
- raise(ArgumentError, "Invalid format for :url: #{@url.inspect}. Should be similar to: 'http://hostname:port/path'") unless @url
104
+ raise(ArgumentError, "Invalid format for :url: #{@url.inspect}. Should be similar to: 'http://hostname:port/path'") unless @server
105
105
 
106
106
  @port = uri.port
107
107
  @username = uri.user if !@username && uri.user
108
108
  @password = uri.password if !@password && uri.password
109
109
  @path = uri.path
110
+ # Path cannot be empty
111
+ @path = '/' if @path == ''
110
112
 
111
113
  if uri.scheme == 'https'
112
114
  @ssl_options ||= {}
@@ -175,9 +175,9 @@ module SemanticLogger
175
175
  end
176
176
 
177
177
  # :nodoc:
178
- def with_payload(payload)
178
+ def with_payload(payload, &block)
179
179
  warn '#with_payload is deprecated, use SemanticLogger.named_tagged'
180
- SemanticLogger.named_tagged(payload)
180
+ SemanticLogger.named_tagged(payload, &block)
181
181
  end
182
182
 
183
183
  # :nodoc:
@@ -67,7 +67,7 @@ module SemanticLogger
67
67
  # Except if there is an exception when it will always be logged
68
68
  if duration
69
69
  self.duration = duration
70
- return false if (duration <= min_duration) && exception.nil?
70
+ return false if (duration < min_duration) && exception.nil?
71
71
  end
72
72
 
73
73
  self.message = message
@@ -52,7 +52,7 @@ module SemanticLogger
52
52
  # Returns [String] name of this host for logging purposes
53
53
  # Note: Not all appenders use `host`
54
54
  def self.host
55
- @@host ||= Socket.gethostname
55
+ @@host ||= Socket.gethostname.force_encoding("UTF-8")
56
56
  end
57
57
 
58
58
  # Override the default host name
@@ -1,3 +1,3 @@
1
1
  module SemanticLogger #:nodoc
2
- VERSION = '4.0.0.beta1'
2
+ VERSION = '4.0.0.beta2'
3
3
  end
@@ -20,7 +20,7 @@ module Appender
20
20
  @appender.stub(:post, -> json, ind { index = ind }) do
21
21
  @appender.info @message
22
22
  end
23
- assert_equal "semantic_logger-#{Time.now.utc.strftime('%Y.%m.%d')}/log", index
23
+ assert_equal "/semantic_logger-#{Time.now.utc.strftime('%Y.%m.%d')}/log", index
24
24
  end
25
25
 
26
26
  SemanticLogger::LEVELS.each do |level|
@@ -44,7 +44,7 @@ class MeasureTest < Minitest::Test
44
44
 
45
45
  describe ':min_duration' do
46
46
  it 'not log when faster' do
47
- assert_equal 'result', @logger.send(measure_level, 'hello world', min_duration: 500) { 'result' } # Measure duration of the supplied block
47
+ assert_equal 'result', @logger.send(measure_level, 'hello world', min_duration: 1000) { 'result' } # Measure duration of the supplied block
48
48
  SemanticLogger.flush
49
49
  assert_nil @mock_logger.message
50
50
  end
@@ -104,7 +104,7 @@ class MeasureTest < Minitest::Test
104
104
 
105
105
  describe ':min_duration' do
106
106
  it 'not log when faster' do
107
- assert_equal 'result', @logger.measure(level, 'hello world', min_duration: 500) { 'result' } # Measure duration of the supplied block
107
+ assert_equal 'result', @logger.measure(level, 'hello world', min_duration: 1000) { 'result' } # Measure duration of the supplied block
108
108
  SemanticLogger.flush
109
109
  assert_nil @mock_logger.message
110
110
  end
@@ -156,7 +156,7 @@ class MeasureTest < Minitest::Test
156
156
 
157
157
  describe ':min_duration' do
158
158
  it 'not log when faster' do
159
- assert_equal 'result', @logger.send(measure_level, message: 'hello world', min_duration: 500) { 'result' } # Measure duration of the supplied block
159
+ assert_equal 'result', @logger.send(measure_level, message: 'hello world', min_duration: 1000) { 'result' } # Measure duration of the supplied block
160
160
  SemanticLogger.flush
161
161
  assert_nil @mock_logger.message
162
162
  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.beta1
4
+ version: 4.0.0.beta2
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-01-05 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby