scrolls 0.3.8 → 0.3.9

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: 034a31a03289b207b07627691c1b34e94269391b
4
- data.tar.gz: 128743101d71f87a8d880b50b75291411fc113d6
3
+ metadata.gz: 764cf377dd151093b60740032200866af5dfe033
4
+ data.tar.gz: ad73c8e48a7baa90366ca0e1a05eea887f719fb3
5
5
  SHA512:
6
- metadata.gz: a9b2e61cdb5ddbb617d541a250120427e874546819936c6cc00ac516b36827589635f20211c1814dd53204d93eb2de7206b9d5ad573eb334b5ddfd7a2e3991ff
7
- data.tar.gz: b2ed49f6e31c968b303ca419a211eb07c47f8d25647e9baa6f3d5de2de6fbe23bacb57ffc458cbb6109980edf83281ea09a2300afd102d8064862b740aa82005
6
+ metadata.gz: 43df84fb536e8f94aa15e99471def2587ad5a8abe73ba018392d4aa9deacfff21eb1d2fbc11458670f43d459fe7a3cedeb190436bd5d93a997f7f2374fd35383
7
+ data.tar.gz: d565408e3abf2d46ce1f0561e9dbee59003f5041bbec07a0bdae3cd099295ec9cbf77c3bd8f2df97b1b15b797c1c7d452c1099df2d59ae53b444cb49e5c32424
@@ -0,0 +1,12 @@
1
+ module Scrolls
2
+ class IOLog
3
+ def initialize(stream)
4
+ stream.sync = true
5
+ @stream = stream
6
+ end
7
+
8
+ def log(data)
9
+ @stream.write("#{data}\n")
10
+ end
11
+ end
12
+ end
data/lib/scrolls/log.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "scrolls/parser"
2
2
  require "scrolls/utils"
3
+ require "scrolls/iolog"
3
4
  require "scrolls/syslog"
4
5
 
5
6
  module Scrolls
@@ -231,27 +232,14 @@ module Scrolls
231
232
  ((finish - start).to_f * @t)
232
233
  end
233
234
 
234
- def mtx
235
- @mtx ||= Mutex.new
236
- end
237
-
238
- def sync_stream(out=nil)
239
- out = STDOUT if out.nil?
240
- s = out
241
- s.sync = true
242
- s
235
+ def sync_stream(out = STDOUT)
236
+ IOLog.new(out)
243
237
  end
244
238
 
245
239
  def write(data)
246
240
  if log_level_ok?(data[:level])
247
241
  msg = unparse(data)
248
- mtx.synchronize do
249
- begin
250
- stream.puts(msg)
251
- rescue NoMethodError => e
252
- raise
253
- end
254
- end
242
+ stream.log(msg)
255
243
  end
256
244
  end
257
245
 
@@ -35,7 +35,7 @@ module Scrolls
35
35
  end
36
36
  end
37
37
 
38
- def puts(data)
38
+ def log(data)
39
39
  @syslog.log(Syslog::LOG_INFO, "%s", data)
40
40
  end
41
41
 
@@ -1,3 +1,3 @@
1
1
  module Scrolls
2
- VERSION = "0.3.8"
2
+ VERSION = "0.3.9"
3
3
  end
data/test/test_scrolls.rb CHANGED
@@ -14,7 +14,7 @@ class TestScrolls < Test::Unit::TestCase
14
14
  end
15
15
 
16
16
  def test_construct
17
- assert_equal StringIO, Scrolls.stream.class
17
+ assert_equal Scrolls::IOLog, Scrolls.stream.class
18
18
  end
19
19
 
20
20
  def test_default_global_context
@@ -130,7 +130,7 @@ class TestScrolls < Test::Unit::TestCase
130
130
 
131
131
  oneline_backtrace = @out.string.gsub("\n", 'XX')
132
132
 
133
- assert_match /test=exception at=exception.*test_log_exception.*XX.*minitest/,
133
+ assert_match /test=exception at=exception.*test_log_exception.*XX/,
134
134
  oneline_backtrace
135
135
  end
136
136
 
@@ -165,6 +165,12 @@ class TestScrolls < Test::Unit::TestCase
165
165
  assert_match /facility=184/, Scrolls.stream.inspect
166
166
  end
167
167
 
168
+ def test_logging_message_with_syslog
169
+ Scrolls.stream = 'syslog'
170
+ Scrolls.facility = 'local7'
171
+ Scrolls.log "scrolls test"
172
+ end
173
+
168
174
  def test_add_timestamp
169
175
  Scrolls.add_timestamp = true
170
176
  Scrolls.log(:test => "foo")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scrolls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Curt Micol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-11 00:00:00.000000000 Z
11
+ date: 2017-08-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Logging, easier, more consistent.
14
14
  email:
@@ -26,6 +26,7 @@ files:
26
26
  - docs/syslog.md
27
27
  - lib/scrolls.rb
28
28
  - lib/scrolls/atomic.rb
29
+ - lib/scrolls/iolog.rb
29
30
  - lib/scrolls/log.rb
30
31
  - lib/scrolls/parser.rb
31
32
  - lib/scrolls/syslog.rb
@@ -56,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
57
  version: '0'
57
58
  requirements: []
58
59
  rubyforge_project:
59
- rubygems_version: 2.2.0
60
+ rubygems_version: 2.6.11
60
61
  signing_key:
61
62
  specification_version: 4
62
63
  summary: When do we log? All the time.