services 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/services/logger/file.rb +1 -1
- data/lib/services/logger/redis.rb +26 -2
- data/lib/services/modules/call_logger.rb +2 -2
- data/lib/services/version.rb +1 -1
- data/spec/services/logger/redis_spec.rb +8 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d81b81f1b90d4c408865594ca48558fe9469e7d
|
4
|
+
data.tar.gz: a33b8e7d9007b638feddadd7270780756a083a0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28c253c6305653cd64b7fed56a905d6b4215f6ca579500ac3c0015f6ed0c682958478771b7a7b45bd90360b86b745bfa8c19b1d5814e845476d65bb1e107747f
|
7
|
+
data.tar.gz: 0942c38383e122fdf186cde9fd278c684d1e2fe8211b82724fb306f6bd168bf8b587abe362c61927a87752326276ef488d331227e856ceabfb39def0453fcb72
|
data/CHANGELOG.md
CHANGED
data/lib/services/logger/file.rb
CHANGED
@@ -1,16 +1,30 @@
|
|
1
1
|
module Services
|
2
2
|
module Logger
|
3
3
|
class Redis
|
4
|
+
META_CLASSES = [
|
5
|
+
NilClass,
|
6
|
+
TrueClass,
|
7
|
+
FalseClass,
|
8
|
+
Symbol,
|
9
|
+
String,
|
10
|
+
Numeric
|
11
|
+
]
|
12
|
+
|
13
|
+
InvalidMetaError = Class.new(StandardError)
|
14
|
+
|
4
15
|
def initialize(redis, key = 'logs')
|
5
16
|
@redis, @key = redis, key
|
6
17
|
end
|
7
18
|
|
8
|
-
def log(message, meta = {}, severity =
|
19
|
+
def log(message, meta = {}, severity = 'info')
|
20
|
+
# Allow only simple data types in meta
|
21
|
+
raise InvalidMetaError, "Meta keys and values must be of one of the following classes: #{META_CLASSES.join(', ')}" if meta_includes_invalid_values?(meta)
|
22
|
+
|
9
23
|
value = {
|
10
24
|
time: Time.now.to_i,
|
11
25
|
message: message.to_s,
|
12
26
|
severity: severity.to_s,
|
13
|
-
meta: meta
|
27
|
+
meta: meta
|
14
28
|
}
|
15
29
|
@redis.lpush @key, value.to_json
|
16
30
|
end
|
@@ -37,6 +51,16 @@ module Services
|
|
37
51
|
data['time'] = Time.at(data['time'])
|
38
52
|
data
|
39
53
|
end
|
54
|
+
|
55
|
+
def meta_includes_invalid_values?(meta)
|
56
|
+
[meta.values, meta.keys].any? do |elements|
|
57
|
+
elements.any? do |element|
|
58
|
+
META_CLASSES.none? do |klass|
|
59
|
+
element.class <= klass
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
40
64
|
end
|
41
65
|
end
|
42
66
|
end
|
@@ -20,8 +20,8 @@ module Services
|
|
20
20
|
|
21
21
|
private
|
22
22
|
|
23
|
-
def log(message, severity =
|
24
|
-
Services.configuration.logger.log message, { service: self.class, id: @id }, severity
|
23
|
+
def log(message, severity = 'info')
|
24
|
+
Services.configuration.logger.log message, { service: self.class.to_s, id: @id }, severity
|
25
25
|
end
|
26
26
|
|
27
27
|
def log_exception(e, cause = false)
|
data/lib/services/version.rb
CHANGED
@@ -12,14 +12,18 @@ describe Services::Logger::Redis do
|
|
12
12
|
severity: :info,
|
13
13
|
meta: {
|
14
14
|
foo: 'bar',
|
15
|
-
class: Services::Base,
|
16
|
-
object: redis
|
15
|
+
class: Services::Base.to_s,
|
16
|
+
object: redis.to_s
|
17
17
|
}
|
18
18
|
}, {
|
19
19
|
time: Date.new(2014, 10, 10),
|
20
20
|
message: "Oh baby, we'll be old",
|
21
21
|
severity: :warning,
|
22
|
-
meta: {
|
22
|
+
meta: {
|
23
|
+
true: true,
|
24
|
+
false: false,
|
25
|
+
nil: nil
|
26
|
+
}
|
23
27
|
}, {
|
24
28
|
time: Date.new(2014, 11, 17),
|
25
29
|
message: 'And think of all the stories',
|
@@ -42,7 +46,7 @@ describe Services::Logger::Redis do
|
|
42
46
|
log[k] = log[k].try(:to_s) || ''
|
43
47
|
end
|
44
48
|
log[:meta] = if log.has_key?(:meta)
|
45
|
-
log[:meta].
|
49
|
+
log[:meta].stringify_keys
|
46
50
|
else
|
47
51
|
{}
|
48
52
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: services
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Meurer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|