blabbermouth 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blabbermouth/blabber.rb +12 -12
- data/lib/blabbermouth/bystanders.rb +1 -0
- data/lib/blabbermouth/bystanders/formatter.rb +12 -0
- data/lib/blabbermouth/bystanders/stdout.rb +12 -17
- data/lib/blabbermouth/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f98803c45f268ba1996c09ea11a80a6ef37c6a1a
|
4
|
+
data.tar.gz: ccd0de0419d5e61031e407f9b836787402c79a1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49cf015a98b558aa260538ad3caf3e9a468a99837e7ebe7e0dc7b8d286f070d3dabe6b2ee27f52067be4a00e5b31ba8b8228c43bba7426104f6470eb023171bf
|
7
|
+
data.tar.gz: 631113f766998dfc7b002cd77b2baca5a39bb853eb522e4a010a7e7b73bc88627f957beeb957c3a59dba0d6b3e85e031fe2792f9dd2d6358ae4f6aa7df253cb3
|
data/lib/blabbermouth/blabber.rb
CHANGED
@@ -62,28 +62,23 @@ module Blabbermouth
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def error(key, e, *args)
|
65
|
-
|
66
|
-
bystanders.map { |bystander| bystander.error key, e, *args.concat([bystander_options(bystander, opts)]) }
|
65
|
+
blab :error, key, e, *args
|
67
66
|
end
|
68
67
|
|
69
68
|
def info(key, msg=nil, *args)
|
70
|
-
|
71
|
-
bystanders.map { |bystander| bystander.info key, msg, *args.concat([bystander_options(bystander, opts)]) }
|
69
|
+
blab :info, key, msg, *args
|
72
70
|
end
|
73
71
|
|
74
72
|
def increment(key, by=1, *args)
|
75
|
-
|
76
|
-
bystanders.map { |bystander| bystander.increment key, by, *args.concat([bystander_options(bystander, opts)]) }
|
73
|
+
blab :increment, key, by, *args
|
77
74
|
end
|
78
75
|
|
79
76
|
def count(key, total, *args)
|
80
|
-
|
81
|
-
bystanders.map { |bystander| bystander.count key, total, *args.concat([bystander_options(bystander, opts)]) }
|
77
|
+
blab :count, key, total, *args
|
82
78
|
end
|
83
79
|
|
84
80
|
def time(key, duration=nil, *args, &block)
|
85
81
|
raise "Blabbermouth::Blabber#time requires a duration or block" if duration.nil? && !block_given?
|
86
|
-
opts = args.extract_options!
|
87
82
|
|
88
83
|
if block_given?
|
89
84
|
start_time = ::Time.now
|
@@ -91,16 +86,21 @@ module Blabbermouth
|
|
91
86
|
duration = (::Time.now - start_time).to_f
|
92
87
|
end
|
93
88
|
|
94
|
-
|
89
|
+
blab :time, key, duration, *args
|
95
90
|
end
|
96
91
|
|
97
|
-
def
|
92
|
+
def blab(meth, key, *args, &block)
|
93
|
+
opts = args.extract_options!
|
98
94
|
bystanders.map do |bystander|
|
99
95
|
next unless bystander.respond_to?(meth)
|
100
|
-
bystander.send
|
96
|
+
bystander.send meth, key, *args.concat([bystander_options(bystander, opts)]), &block
|
101
97
|
end
|
102
98
|
end
|
103
99
|
|
100
|
+
def method_missing(meth, *args, &block)
|
101
|
+
blab meth, *args, &block
|
102
|
+
end
|
103
|
+
|
104
104
|
def respond_to_missing?(meth, include_private=false)
|
105
105
|
bystanders.any? { |bystander| bystander.respond_to?(meth, include_private) }
|
106
106
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Blabbermouth
|
2
|
+
module Bystanders
|
3
|
+
module Formatter
|
4
|
+
def log_message(event, key, msg, data={})
|
5
|
+
message = "[#{::Time.now.strftime('%Y/%m/%d %H:%M:%S %Z')}] Blabbermouth.#{event.to_s}: #{key.to_s}"
|
6
|
+
message += ": #{msg.to_s}" unless msg.to_s.blank?
|
7
|
+
message += " #{data.to_s}"
|
8
|
+
message
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -1,29 +1,31 @@
|
|
1
1
|
module Blabbermouth
|
2
2
|
module Bystanders
|
3
3
|
class Stdout < Base
|
4
|
+
include Blabbermouth::Bystanders::Formatter
|
5
|
+
|
4
6
|
def error(key, e, *args)
|
5
|
-
|
6
|
-
puts :error, key, e.message, data
|
7
|
+
blab :error, key, e, *args
|
7
8
|
end
|
8
9
|
|
9
10
|
def info(key, msg=nil, *args)
|
10
|
-
|
11
|
-
puts :info, key, msg, data
|
11
|
+
blab :info, key, msg, *args
|
12
12
|
end
|
13
13
|
|
14
14
|
def increment(key, by=1, *args)
|
15
|
-
|
16
|
-
puts :increment, key, by, data
|
15
|
+
blab :increment, key, by, *args
|
17
16
|
end
|
18
17
|
|
19
18
|
def count(key, total, *args)
|
20
|
-
|
21
|
-
puts :count, key, total, data
|
19
|
+
blab :count, key, total, *args
|
22
20
|
end
|
23
21
|
|
24
|
-
def time(key,
|
22
|
+
def time(key, duration, *args)
|
23
|
+
blab :time, key, duration, *args
|
24
|
+
end
|
25
|
+
|
26
|
+
def blab(meth, key, value, *args)
|
25
27
|
data, opts, args = parse_args(*args)
|
26
|
-
puts
|
28
|
+
puts meth, key, value, data
|
27
29
|
end
|
28
30
|
|
29
31
|
protected
|
@@ -31,13 +33,6 @@ module Blabbermouth
|
|
31
33
|
def puts(event, key, msg, data={})
|
32
34
|
$stdout.puts log_message(event, key, msg, data)
|
33
35
|
end
|
34
|
-
|
35
|
-
def log_message(event, key, msg, data={})
|
36
|
-
message = "[#{::Time.now.strftime('%Y/%m/%d %H:%M:%S %Z')}] Blabbermouth.#{event.to_s}: #{key.to_s}"
|
37
|
-
message += ": #{msg.to_s}" unless msg.to_s.blank?
|
38
|
-
message += " #{data.to_s}"
|
39
|
-
message
|
40
|
-
end
|
41
36
|
end
|
42
37
|
end
|
43
38
|
end
|
data/lib/blabbermouth/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blabbermouth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Rebec
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- lib/blabbermouth/blabber.rb
|
66
66
|
- lib/blabbermouth/bystanders.rb
|
67
67
|
- lib/blabbermouth/bystanders/base.rb
|
68
|
+
- lib/blabbermouth/bystanders/formatter.rb
|
68
69
|
- lib/blabbermouth/bystanders/new_relic.rb
|
69
70
|
- lib/blabbermouth/bystanders/stdout.rb
|
70
71
|
- lib/blabbermouth/configuration.rb
|