lamian 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lamian.rb +4 -12
- data/lib/lamian/config.rb +1 -0
- data/lib/lamian/engine.rb +1 -0
- data/lib/lamian/logger.rb +28 -38
- data/lib/lamian/middleware.rb +2 -3
- data/lib/lamian/version.rb +1 -1
- metadata +16 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af55048dfae57a8cb4c142cc91a3e184a840df54
|
4
|
+
data.tar.gz: 259f504ea8d043659adfa66a736974e6f1c0d344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 605dcc50b3472cd341dd9ea3f8aceae8a0c180679f19bf86189d1c02783d61eba98ef6ce7096cf25851de11bbfb5137633e3cd544793bf5999d388dafc73e949
|
7
|
+
data.tar.gz: a5b1b27b04d6bcb2a184c8a4acb4e1dec2f2f99f650fb605ca5e7c49e57ad408c23fc9cda35dbdd013d24d780021520bc056b734549ae65ab2ffecb14246fa90
|
data/lib/lamian.rb
CHANGED
@@ -25,20 +25,12 @@ module Lamian
|
|
25
25
|
Lamian::Logger.current
|
26
26
|
end
|
27
27
|
|
28
|
-
def
|
29
|
-
logger.
|
28
|
+
def run
|
29
|
+
logger.run { yield }
|
30
30
|
end
|
31
31
|
|
32
|
-
def
|
33
|
-
logger.
|
34
|
-
end
|
35
|
-
|
36
|
-
def dump(*args, &block)
|
37
|
-
logger.dump(*args, &block)
|
38
|
-
end
|
39
|
-
|
40
|
-
def stop
|
41
|
-
logger.stop
|
32
|
+
def dump
|
33
|
+
logger.dump
|
42
34
|
end
|
43
35
|
end
|
44
36
|
end
|
data/lib/lamian/config.rb
CHANGED
data/lib/lamian/engine.rb
CHANGED
data/lib/lamian/logger.rb
CHANGED
@@ -8,60 +8,50 @@ module Lamian
|
|
8
8
|
Thread.current[:__lamian_logger] ||= new
|
9
9
|
end
|
10
10
|
|
11
|
-
def initialize
|
12
|
-
self.running = running
|
11
|
+
def initialize
|
13
12
|
self.level = 0
|
14
|
-
|
13
|
+
self.logdevs = []
|
14
|
+
self.formatter = Lamian.config.formatter
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
self.running = true
|
23
|
-
end
|
17
|
+
def run
|
18
|
+
push_logdev(StringIO.new)
|
19
|
+
yield
|
20
|
+
ensure
|
21
|
+
pop_logdev
|
24
22
|
end
|
25
23
|
|
26
|
-
def
|
27
|
-
|
24
|
+
def add(*args, &block)
|
25
|
+
each_logdev { super(*args, &block) }
|
28
26
|
end
|
29
27
|
|
30
28
|
def dump(format: nil)
|
31
|
-
result =
|
32
|
-
|
29
|
+
result = logdevs[-1].string.dup
|
30
|
+
formatter ? apply_format(format, result) : result
|
33
31
|
end
|
34
32
|
|
35
|
-
|
36
|
-
self.running = false
|
37
|
-
dump
|
38
|
-
end
|
33
|
+
private
|
39
34
|
|
40
|
-
|
41
|
-
return unless running?
|
42
|
-
self.formatter = Lamian.config.formatter
|
43
|
-
super
|
44
|
-
end
|
35
|
+
attr_accessor :level, :logdevs, :formatter
|
45
36
|
|
46
|
-
|
37
|
+
def apply_format(_format, result)
|
38
|
+
result.gsub!(/\[\d{1,2}m/)
|
39
|
+
result
|
40
|
+
end
|
47
41
|
|
48
|
-
def
|
49
|
-
|
50
|
-
text
|
42
|
+
def push_logdev(logdev)
|
43
|
+
logdevs << logdev
|
51
44
|
end
|
52
45
|
|
53
|
-
|
54
|
-
|
46
|
+
def pop_logdev
|
47
|
+
logdevs.pop
|
48
|
+
end
|
55
49
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
stop
|
62
|
-
ensure
|
63
|
-
self.logdev = old_logdev
|
64
|
-
self.running = old_running
|
50
|
+
def each_logdev
|
51
|
+
logdevs.each do |logdev|
|
52
|
+
@logdev = logdev
|
53
|
+
yield
|
54
|
+
end
|
65
55
|
end
|
66
56
|
end
|
67
57
|
end
|
data/lib/lamian/middleware.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Lamian
|
2
3
|
class Middleware
|
3
4
|
def initialize(app)
|
@@ -5,9 +6,7 @@ module Lamian
|
|
5
6
|
end
|
6
7
|
|
7
8
|
def call(env)
|
8
|
-
|
9
|
-
Lamian.start { result = app.call(env) }
|
10
|
-
result
|
9
|
+
Lamian.run { app.call(env) }
|
11
10
|
end
|
12
11
|
|
13
12
|
private
|
data/lib/lamian/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lamian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JelF
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0.10'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: coveralls
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.8'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.8'
|
111
125
|
description: Add logs to your error messages, using exception_notifier or smth like
|
112
126
|
it
|
113
127
|
email:
|
@@ -149,4 +163,3 @@ signing_key:
|
|
149
163
|
specification_version: 4
|
150
164
|
summary: Add logs to your error messages
|
151
165
|
test_files: []
|
152
|
-
has_rdoc:
|