rad_core 0.0.16 → 0.0.17
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/components/logger.rb
CHANGED
@@ -34,9 +34,8 @@ class ControllerErrorHandling < Rad::Conveyors::Processor
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
|
37
|
-
DEFAULT_ERROR_HANDLER = lambda{|e, format|
|
37
|
+
DEFAULT_ERROR_HANDLER = lambda{|e, format|
|
38
38
|
tname = rad.controller.send("#{rad.mode}_error_template")
|
39
|
-
|
40
39
|
if tname and rad.template.exist?(tname, format: format, exact_format: true)
|
41
40
|
data = rad.template.render(tname,
|
42
41
|
format: format,
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class Rad::Logger
|
2
|
-
def initialize stream
|
2
|
+
def initialize stream = nil
|
3
3
|
@stream = stream
|
4
4
|
end
|
5
5
|
|
@@ -13,25 +13,29 @@ class Rad::Logger
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def info obj
|
16
|
-
|
16
|
+
write obj_to_string(obj) + "\n"
|
17
17
|
end
|
18
18
|
|
19
19
|
def warn obj
|
20
|
-
|
20
|
+
write "WARN: " + obj_to_string(obj) + "\n"
|
21
21
|
end
|
22
22
|
|
23
23
|
def error obj
|
24
|
-
|
24
|
+
write "ERROR: " + obj_to_string(obj) + "\n"
|
25
25
|
end
|
26
26
|
|
27
27
|
def debug obj
|
28
|
-
|
29
|
-
# cutting annoying BSON::ObjectId('4dec6a8d360501476d000004') stuff
|
30
|
-
stream.write(indent(obj_to_string(obj).gsub(/BSON::ObjectId\(([a-z0-9'"]+)\)/, "\\1")) + "\n")
|
31
|
-
end
|
28
|
+
write obj_to_string(obj).gsub(/BSON::ObjectId\(([a-z0-9'"]+)\)/, "\\1") + "\n"
|
32
29
|
end
|
33
30
|
|
34
31
|
protected
|
32
|
+
def write str
|
33
|
+
if !@silence
|
34
|
+
str = indent(str)
|
35
|
+
stream ? stream.write(str) : puts(str)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
35
39
|
IDENTATION = " "
|
36
40
|
attr_reader :stream
|
37
41
|
|