scrolls 0.0.7 → 0.0.8
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.
- data/lib/scrolls/version.rb +1 -1
- data/lib/scrolls.rb +28 -3
- metadata +2 -2
data/lib/scrolls/version.rb
CHANGED
data/lib/scrolls.rb
CHANGED
@@ -16,6 +16,20 @@ module Scrolls
|
|
16
16
|
module Log
|
17
17
|
extend self
|
18
18
|
|
19
|
+
LOG_LEVEL = (ENV["LOG_LEVEL"] || 3).to_i
|
20
|
+
|
21
|
+
#http://tools.ietf.org/html/rfc5424#page-11
|
22
|
+
LOG_LEVEL_MAP = {
|
23
|
+
"emergency" => 0,
|
24
|
+
"alert" => 1,
|
25
|
+
"critical" => 2,
|
26
|
+
"error" => 3,
|
27
|
+
"warning" => 4,
|
28
|
+
"notice" => 5,
|
29
|
+
"info" => 6,
|
30
|
+
"debug" => 7
|
31
|
+
}
|
32
|
+
|
19
33
|
attr_accessor :stream
|
20
34
|
|
21
35
|
def start(out = nil)
|
@@ -36,9 +50,11 @@ module Scrolls
|
|
36
50
|
end
|
37
51
|
|
38
52
|
def write(data)
|
39
|
-
|
40
|
-
|
41
|
-
|
53
|
+
if log_level_ok?(data[:level])
|
54
|
+
msg = unparse(data)
|
55
|
+
mtx.synchronize do
|
56
|
+
@stream.puts(msg)
|
57
|
+
end
|
42
58
|
end
|
43
59
|
end
|
44
60
|
|
@@ -105,5 +121,14 @@ module Scrolls
|
|
105
121
|
end
|
106
122
|
end
|
107
123
|
end
|
124
|
+
|
125
|
+
def log_level_ok?(level)
|
126
|
+
if level
|
127
|
+
LOG_LEVEL_MAP[level.to_s] <= LOG_LEVEL
|
128
|
+
else
|
129
|
+
true
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
108
133
|
end
|
109
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scrolls
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Logging, easier, more consistent.
|
15
15
|
email:
|