lines 0.1.20 → 0.1.21

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGU4YzQzOTg2NjJlNWFjNjA2ZDliYzEzYTRkMDE3OWJjZGRjZmI0NQ==
4
+ YzZjZDcxM2I5YjM2OTUyMmI2YmZlZmI2ZWRhNzgxMmJlNTVkM2E5MQ==
5
5
  data.tar.gz: !binary |-
6
- NzIzODU1MzljMTg5N2I1MzVhMjdlN2EwOTE4YmVlY2ZlMjE4NDM4Yg==
6
+ ZGVhNDVhOTUyYzQzZDY3YTBiOWQ1NmExMTc4MTlhMWZkNGZiY2YxZQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YmQ0MGI3ODU4ZWJhNDM1NzA5ZDlmMWI2NjNiMmFjMDQ2YjZjZDExZjExMjk4
10
- MDFlZWQyMmRmY2IxZjY4NDc1ODljZmI3NmYwZTkzZjBiYjUwZWY0OWI4MjU4
11
- ZDE3NThhMDhhMWY5NTlkYWZhY2M3YjcwMjZhY2Q2MzlhZDNlNjE=
9
+ MmYzMGZiNGVkOTAwZjJiY2ViOGY3OGI2NGYyYTYwZDRiNzU3MmZkMWViOGNh
10
+ ODYzZjJjNDRmNTA2NmM2ODA2MjY2ZmVhODhmMjcyZDQ1MjY5OTJlZjE1NDgw
11
+ N2Q2ZWQxYjk1OTJjYzRhNWQ0ZmE1OTZlMmEwMTJkMTkzNmZlYTQ=
12
12
  data.tar.gz: !binary |-
13
- OTg1YjllMzkyNjMzNmIwZjdmYTU2MDQzZmIzNmNmY2IyOTE5ZTJiNDkwYWRi
14
- M2U1YWE5OWEzNjk5YjkzMmU2OWFlZDRjMWI1NzZmNjVjOWQwY2NkNmY3NmYx
15
- MjIzNWFjMjNmNjllMGZlZDBlNTljNzMwZmE4OWUzYjMzZWIzYTQ=
13
+ MTU4N2I1MGUwYTM4ZTZhOWU2MGMzNjQwOGE3MWQzN2M1ODI2ZDQyZjQ4MmI4
14
+ ZWJiNWI3YTcxYzIwNWNjMzMyZGU1ZDE5NmZiZGRiMTUyMjUyYTllMDYzNzll
15
+ YmE1NDA3YjQ2ZjM2OGY5NTAwNWRjNGYyMGVlYjQ3MTM2MmM3ZWM=
@@ -0,0 +1,8 @@
1
+
2
+ n.n.n / 2013-06-27
3
+ ==================
4
+
5
+ * Return self when silencing the Rack::CommonLogger
6
+ * Use Lines as the default ActiveRecord::Base logger
7
+ * Catch errors from global procs
8
+
@@ -103,7 +103,7 @@ module Lines
103
103
  args = ensure_hash!(args)
104
104
 
105
105
  g = global.inject({}) do |h, (k,v)|
106
- h[k] = v.respond_to?(:call) ? v.call : v
106
+ h[k] = (v.respond_to?(:call) ? v.call : v) rescue $!
107
107
  h
108
108
  end
109
109
 
@@ -29,8 +29,9 @@ module Lines
29
29
  Lines.log(name: event.payload[:name], line: event.payload[:line])
30
30
  end
31
31
 
32
- def logger; true; end
32
+ def logger; Lines.logger; end
33
33
  end
34
34
  end
35
35
 
36
+ ActiveRecord::Base.logger = Lines.logger
36
37
  Lines::ActiveRecordSubscriber.attach_to :active_record
@@ -6,6 +6,7 @@ module Lines
6
6
  # In development mode the common logger is always inserted
7
7
  def self.silence_common_logger!
8
8
  Rack::CommonLogger.module_eval("def call(env); @app.call(env); end")
9
+ self
9
10
  end
10
11
 
11
12
  def initialize(app)
@@ -1,3 +1,3 @@
1
1
  module Lines
2
- VERSION = "0.1.20"
2
+ VERSION = "0.1.21"
3
3
  end
@@ -0,0 +1,55 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'lines'
3
+
4
+ module Kernel
5
+ def bm(name = nil, &what)
6
+ start = Time.now.to_f
7
+ count = 0
8
+ max = 0.5
9
+ name ||= what.source_location.join(':')
10
+ $stdout.write "#{name} : "
11
+ while Time.now.to_f - start < max
12
+ yield
13
+ count += 1
14
+ end
15
+ $stdout.puts "%0.3f fps" % (count / max)
16
+ end
17
+ end
18
+
19
+ class FakeIO
20
+ def write(*a)
21
+ end
22
+ alias syswrite write
23
+ end
24
+
25
+ Lines.global[:app] = 'benchmark'
26
+ Lines.global[:at] = proc{ Time.now }
27
+ Lines.global[:pid] = Process.pid
28
+
29
+ EX = (raise "FOO" rescue $!)
30
+
31
+ Lines.use FakeIO.new
32
+ bm "FakeIO write" do
33
+ Lines.log EX
34
+ end
35
+
36
+ dev_null = File.open('/dev/null', 'w')
37
+ Lines.use dev_null
38
+ bm "/dev/null write" do
39
+ Lines.log EX
40
+ end
41
+
42
+ Lines.use Syslog
43
+ bm "syslog write" do
44
+ Lines.log EX
45
+ end
46
+
47
+ real_file = File.open('real_file.log', 'w')
48
+ Lines.use real_file
49
+ bm "real file" do
50
+ Lines.log EX
51
+ end
52
+
53
+ bm "real file logger" do
54
+ Lines.logger.info "Ahoi this is a really cool option"
55
+ end
@@ -90,6 +90,12 @@ describe Lines do
90
90
  'count=2 msg=test2' + Lines::NL
91
91
  )
92
92
  end
93
+
94
+ it "doesn't fail if a proc has an exception" do
95
+ Lines.global[:X] = proc{ fail "error" }
96
+ Lines.log 'test'
97
+ expect(output).to eq("X='#<RuntimeError: error>' msg=test" + Lines::NL)
98
+ end
93
99
  end
94
100
  end
95
101
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lines
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20
4
+ version: 0.1.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Pfenniger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-06-26 00:00:00.000000000 Z
11
+ date: 2013-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -48,6 +48,7 @@ files:
48
48
  - .gitignore
49
49
  - .rspec
50
50
  - .travis.yml
51
+ - CHANGELOG.md
51
52
  - Gemfile
52
53
  - LICENSE.txt
53
54
  - README.md
@@ -59,6 +60,7 @@ files:
59
60
  - lib/lines/rack_logger.rb
60
61
  - lib/lines/version.rb
61
62
  - lines.gemspec
63
+ - spec/bench.rb
62
64
  - spec/lines_loader_spec.rb
63
65
  - spec/lines_spec.rb
64
66
  - spec/spec_helper.rb
@@ -87,6 +89,7 @@ signing_key:
87
89
  specification_version: 4
88
90
  summary: Lines is an opinionated structured logging library
89
91
  test_files:
92
+ - spec/bench.rb
90
93
  - spec/lines_loader_spec.rb
91
94
  - spec/lines_spec.rb
92
95
  - spec/spec_helper.rb