ztk 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/ztk/logger.rb +4 -1
- data/lib/ztk/version.rb +1 -1
- data/spec/ztk/logger_spec.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NGVjMmUxNzUxNjk2NGUxY2FkYTYyMWU5YWM0ODZmYzUzYTViYTZlNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Zjc5OTRiOWM2ZWYxZDJiMDdjZjc3ZDU5NzcyMmE5ZDQ3Y2JlZDVkMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDZlZGMyYmI0M2U4Zjc2YTA5ZjNlMzZkNDEzODhmY2NiNDQ5MzIzMTg0OGJk
|
10
|
+
YTEyZWI2ZmI0OTYzMjdjMWQ2Yzk1ODAxOWJmZGE4NGRmYzViOGM3M2I3ZTMw
|
11
|
+
MjA4ZTUwOTk1NThmNmQ3ZjA5MmJkMDVlNTNmYTRhMTU2NWM1OGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTJmMGY5NGIyMjgyZGUwMGE4MjUyMmMyMDljY2RlYThjMjc5NGViYTNmZTQx
|
14
|
+
MDNkNWU0MThhZjJiZjBhMGY2MzI3NGUwNjY0YWIxZjYxNDUzNTU5ZGUzY2Rm
|
15
|
+
YTZlNjdmN2FiN2RjNzQ2OTRhOTIyNDAzYmYyYjA4YmY0ZWE2Zjk=
|
data/lib/ztk/logger.rb
CHANGED
@@ -24,6 +24,7 @@ module ZTK
|
|
24
24
|
#
|
25
25
|
# @author Zachary Patten <zachary AT jovelabs DOT com>
|
26
26
|
class Logger < ::Logger
|
27
|
+
attr_accessor :stdout_echo
|
27
28
|
|
28
29
|
# Log Levels
|
29
30
|
SEVERITIES = Severity.constants.inject([]) {|arr,c| arr[Severity.const_get(c)] = c; arr}
|
@@ -95,7 +96,9 @@ module ZTK
|
|
95
96
|
message = [message, progname].flatten.compact.join(": ")
|
96
97
|
message = "%19s.%06d|%05d|%5s|%s%s\n" % [Time.now.utc.strftime("%Y-%m-%d|%H:%M:%S"), Time.now.utc.usec, Process.pid, SEVERITIES[severity], called_by, message]
|
97
98
|
|
98
|
-
|
99
|
+
statement = ZTK::ANSI.uncolor(message)
|
100
|
+
stdout_echo.nil? or $stdout.write(statement)
|
101
|
+
@logdev.write(statement)
|
99
102
|
@logdev.respond_to?(:flush) and @logdev.flush
|
100
103
|
|
101
104
|
true
|
data/lib/ztk/version.rb
CHANGED
data/spec/ztk/logger_spec.rb
CHANGED
@@ -89,6 +89,19 @@ describe ZTK::Logger do
|
|
89
89
|
IO.read(@logfile).match(data).should_not be nil
|
90
90
|
end
|
91
91
|
|
92
|
+
it "should allow us to echo log statements to STDOUT" do
|
93
|
+
data = "Hello World"
|
94
|
+
stdout = StringIO.new
|
95
|
+
|
96
|
+
$stdout = stdout
|
97
|
+
|
98
|
+
subject.stdout_echo = true
|
99
|
+
subject.debug { data }
|
100
|
+
|
101
|
+
stdout.rewind
|
102
|
+
stdout.read.match(data).should_not be nil
|
103
|
+
end
|
104
|
+
|
92
105
|
end
|
93
106
|
|
94
107
|
describe "log message" do
|