complain 1.0.0 → 1.0.1
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 +4 -4
- data/README.md +0 -2
- data/lib/complain.rb +21 -6
- data/lib/complain/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faccbd58fd96f069387098f98b534ad68ea14df6
|
4
|
+
data.tar.gz: 0544e7958322b2b8b5ae1bac4f7a6692901f9666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8c6aef76d026d1b6d0b52f3651841764cfb71387f09fb786f8c1f88ce898d795a77020231c60304e2f0f9059a2acca34a85376e568d7f830fc551954fa87c13
|
7
|
+
data.tar.gz: 612b7ec3fb72c233c42a08da250161e5c38ec324753d8b20bea7797a4e38c0828e970b90e46784725a035e94894289b64bf5d1d49f378cbfc3d08235da3783cd
|
data/README.md
CHANGED
data/lib/complain.rb
CHANGED
@@ -16,22 +16,37 @@ module Complain
|
|
16
16
|
# Calls exception writer
|
17
17
|
# @param [Exception] exc Exception to write.
|
18
18
|
# @param [Mixed] logger Logger - can be `:stderr`, `:stdout` or should respond to `error` or `puts`
|
19
|
+
# @option [Boolean] :with_time - Write time to log, default: false
|
20
|
+
# @option [Boolean] :prefix - Prefix for entire log message (empty by default)
|
21
|
+
# @option [Boolean] :postfix - Postfix for entire log message (empty by default)
|
22
|
+
# @option [Boolean] :separator - String to use for concatenation ("\n" by default)
|
19
23
|
# @option [Boolean] :skip_exc - By default (false) internal exceptions will be rescued and written to logger,
|
20
24
|
# and exception will be raised only if second writing is failed;
|
21
25
|
# when set to true exception will not be handled.
|
22
|
-
def self.call(exc,
|
26
|
+
def self.call(exc,
|
27
|
+
logger = :stderr,
|
28
|
+
with_time: false,
|
29
|
+
prefix: '',
|
30
|
+
postfix: '',
|
31
|
+
separator: "\n",
|
32
|
+
skip_exc: false)
|
33
|
+
|
23
34
|
message = if exc.is_a?(Exception)
|
24
|
-
[exc.message, exc.backtrace.join(
|
35
|
+
[exc.message, exc.backtrace.join(separator)]
|
25
36
|
elsif exc.is_a?(String)
|
26
|
-
exc
|
37
|
+
[exc]
|
27
38
|
elsif exc.respond_to?(:to_s)
|
28
|
-
exc.to_s
|
39
|
+
[exc.to_s]
|
29
40
|
elsif exc.respond_to?(:inspect)
|
30
|
-
exc.inspect
|
41
|
+
[exc.inspect]
|
31
42
|
else
|
32
|
-
"Message can't be processed at #{caller.join(
|
43
|
+
["Message can't be processed at #{caller.join(separator)}"]
|
33
44
|
end
|
34
45
|
|
46
|
+
message.unshift(Time.now.to_s) if with_time
|
47
|
+
message = message.join(separator)
|
48
|
+
message = prefix + message + postfix
|
49
|
+
|
35
50
|
if logger.nil? || :stderr == logger
|
36
51
|
$stderr.puts message
|
37
52
|
elsif :stdout == logger
|
data/lib/complain/version.rb
CHANGED