plogger 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +1 -1
- data/lib/Plogger/formatter.rb +16 -4
- data/lib/Plogger/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: b1a7e854fc7e5332fb9c545f4077a2ad76e4aa7f
|
4
|
+
data.tar.gz: 5a78f2866a1dbc345093c72a26e99e47171a8abb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad18a381f52eea6562c3c4ca5484113db042a1983b2428780fe9dd51348c1a3445b1a3f03b0668a164ca422bbe0d02141b9d0dcad65a6b6fe9a662aa2cc3752f
|
7
|
+
data.tar.gz: d4788a60119670664487f7e4b8f9e4a3d552e26d4f9380c8f8f0823b790df4f6b1551d20faac995398e12532b6bd95e6417dfab08a09e4b7fdf7a5ab9fa239fd
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -55,5 +55,5 @@ Example call:
|
|
55
55
|
|
56
56
|
```ruby
|
57
57
|
Plogger.info("Processing ready", type: 'user', category: "Bundle Creation", user_id: 1, extra_info: {happy: "yes"})
|
58
|
-
# Will output 'Processing ready -- type='user' category='Bundle Creation' user_id=1 happy='yes'
|
58
|
+
# Will output 'Processing ready -- trace=194fjx43gp type='user' category='Bundle Creation' user_id=1 happy='yes'
|
59
59
|
```
|
data/lib/Plogger/formatter.rb
CHANGED
@@ -1,12 +1,24 @@
|
|
1
1
|
module Plogger
|
2
2
|
class Formatter
|
3
|
-
def self.format(message, trace, type: 'system', user_id:
|
4
|
-
result = "#{message} --
|
3
|
+
def self.format(message, trace, type: 'system', user_id: nil, account_id: nil, category: '', extra_info: {})
|
4
|
+
result = "#{message} -- trace='#{trace}'"
|
5
|
+
args = {type: type, category: category, user_id: user_id, account_id: account_id}
|
6
|
+
args.each do |key, value|
|
7
|
+
result = add_param_to_message(result, key, value) unless value.nil?
|
8
|
+
end
|
9
|
+
|
5
10
|
extra_info.keys.each do |key|
|
6
|
-
|
7
|
-
result += " #{key}=#{is_string ? "'" : ''}#{extra_info[key]}#{is_string ? "'" : ''}"
|
11
|
+
result = add_param_to_message(result, key, extra_info[key])
|
8
12
|
end
|
9
13
|
result
|
10
14
|
end
|
15
|
+
|
16
|
+
def self.add_param_to_message(message, key, value)
|
17
|
+
result = message
|
18
|
+
is_string = value.class == String
|
19
|
+
result += " #{key}=#{is_string ? "'" : ''}#{value}#{is_string ? "'" : ''}"
|
20
|
+
result
|
21
|
+
end
|
22
|
+
|
11
23
|
end
|
12
24
|
end
|
data/lib/Plogger/version.rb
CHANGED