rt-logman 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +22 -22
- data/lib/logman/version.rb +1 -1
- data/lib/logman.rb +4 -3
- 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: 3532e63f6b57a4160f02ef0d59b85b66ebb8eff6
|
4
|
+
data.tar.gz: 728484d7773b6767795a6a1b1cb474fb55e6bab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c975db44a0a5d3721f2fc81267d45a4a7ba4c9e1a75841c0506ff5abdc29df2a51713a0654772d247c87f350e1a6c93cea47a82da7aad193856d5dc0c29e7fc
|
7
|
+
data.tar.gz: 5435f732788c988d6303a6c56783ccea9e09edb0251f64c04d3830098729a38c54a9446294fbedce1fc877602e8fa825ec255f3c468fdf7f817df11e0324225e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,7 +21,7 @@ To log an informative message to STDOUT, use the following code snippet:
|
|
21
21
|
Logman.info("Hello World")
|
22
22
|
|
23
23
|
# Output:
|
24
|
-
# level
|
24
|
+
# {"level":"INFO","time":"2017-12-12 09:33:00 +0000","pid":10950,"message":"Hello World"}
|
25
25
|
```
|
26
26
|
|
27
27
|
Every log event can be extended with metadata — a hash with key value pairs:
|
@@ -30,7 +30,7 @@ Every log event can be extended with metadata — a hash with key value pairs:
|
|
30
30
|
Logman.info("Hello World", :from => "renderedtext", :to => "The World")
|
31
31
|
|
32
32
|
# Output:
|
33
|
-
# level
|
33
|
+
# {"level":"INFO","time":"2017-12-12 09:33:21 +0000","pid":10950,"message":"Hello World","from":"renderedtext","to":"The World"}
|
34
34
|
```
|
35
35
|
|
36
36
|
Every log event has a severity. In the previous examples we have used `info`. To
|
@@ -40,7 +40,7 @@ log an `error` use the following snippet:
|
|
40
40
|
Logman.error("Team does not exists", :owner => "renderedtext", :team_name => "z-fightes")
|
41
41
|
|
42
42
|
# Output:
|
43
|
-
# level
|
43
|
+
# {"level":"ERROR","time":"2017-12-12 09:33:47 +0000","pid":10950,"message":"Team does not exists","owner":"renderedtext","team_name":"z-fightes"}
|
44
44
|
```
|
45
45
|
|
46
46
|
Logman supports multiple severity levels:
|
@@ -95,7 +95,7 @@ class VideoProcessor
|
|
95
95
|
|
96
96
|
@logger.info("finished")
|
97
97
|
rescue => exception
|
98
|
-
@logger.error("failed", :
|
98
|
+
@logger.error("failed", :exception => exception.message)
|
99
99
|
|
100
100
|
raise
|
101
101
|
end
|
@@ -106,18 +106,18 @@ end
|
|
106
106
|
In case of a successful processing of a video, we would see the following:
|
107
107
|
|
108
108
|
``` txt
|
109
|
-
level
|
110
|
-
level
|
111
|
-
level
|
112
|
-
level
|
113
|
-
level
|
109
|
+
{"level":"INFO","time":"2017-12-12 09:35:19 +0000","pid":10950,"message":"started","compoent":"video_processor","id":9312,"title":"Keyboard Cat"}
|
110
|
+
{"level":"INFO","time":"2017-12-12 09:35:34 +0000","pid":10950,"message":"loaded into memory","compoent":"video_processor","id":9312,"title":"Keyboard Cat","size":41241241}
|
111
|
+
{"level":"INFO","time":"2017-12-12 09:35:44 +0000","pid":10950,"message":"compressed","compoent":"video_processor","id":9312,"title":"Keyboard Cat","size":1312312}
|
112
|
+
{"level":"INFO","time":"2017-12-12 09:36:08 +0000","pid":10950,"message":"uploaded to S3","compoent":"video_processor","id":9312,"title":"Keyboard Cat","s3_path":"s3://hehe/a.mpeg"}
|
113
|
+
{"level":"INFO","time":"2017-12-12 09:36:27 +0000","pid":10950,"message":"finished","compoent":"video_processor","id":9312,"title":"Keyboard Cat"}
|
114
114
|
```
|
115
115
|
|
116
116
|
In case of an error, we would see the following:
|
117
117
|
|
118
118
|
``` txt
|
119
|
-
level
|
120
|
-
level
|
119
|
+
{"level":"INFO","time":"2017-12-12 09:35:19 +0000","pid":10950,"message":"started","compoent":"video_processor","id":9312,"title":"Keyboard Cat"}
|
120
|
+
{"level":"ERROR","time":"2017-12-12 09:35:34 +0000","pid":10950,"message":"failed","compoent":"video_processor","id":9312,"title":"Keyboard Cat","size":41241241,"exception": "Out of memory"}
|
121
121
|
```
|
122
122
|
|
123
123
|
Logman can receive a [Ruby Logger](http://ruby-doc.org/stdlib-2.2.0/libdoc/logger/rdoc/Logger.html)
|
@@ -151,7 +151,7 @@ create a new Logman instance with the same fields as the previous instance:
|
|
151
151
|
|
152
152
|
@team_api_logger.info("Hello")
|
153
153
|
|
154
|
-
# level
|
154
|
+
# {"level":"INFO","time":"2017-12-12 09:39:07 +0000","pid":10950,"message":"Hello","version":"v2"}
|
155
155
|
```
|
156
156
|
|
157
157
|
With Logman, you can instrument data processing with a logger block. For
|
@@ -166,18 +166,18 @@ Logman.process("user-registration", :username => "shiroyasha") do |logger|
|
|
166
166
|
logger.info("Sent signup email")
|
167
167
|
|
168
168
|
team.add(user)
|
169
|
-
logger.info("Added user to a team", :team_id => team)
|
169
|
+
logger.info("Added user to a team", :team_id => team.id)
|
170
170
|
end
|
171
171
|
```
|
172
172
|
|
173
173
|
The above will log the following information:
|
174
174
|
|
175
175
|
``` txt
|
176
|
-
level
|
177
|
-
level
|
178
|
-
level
|
179
|
-
level
|
180
|
-
level
|
176
|
+
{"level":"INFO","time":"2017-12-12 09:40:39 +0000","pid":10950,"message":"user-registration-started","username":"shiroyasha"}
|
177
|
+
{"level":"INFO","time":"2017-12-12 09:40:39 +0000","pid":10950,"message":"User Record Created","username":"shiroyasha"}
|
178
|
+
{"level":"INFO","time":"2017-12-12 09:40:39 +0000","pid":10950,"message":"Sent signup email","username":"shiroyasha"}
|
179
|
+
{"level":"INFO","time":"2017-12-12 09:40:39 +0000","pid":10950,"message":"Added user to a team","username":"shiroyasha","team_id":21}
|
180
|
+
{"level":"INFO","time":"2017-12-12 09:40:39 +0000","pid":10950,"message":"user-registration-finished","username":"shiroyasha"}
|
181
181
|
```
|
182
182
|
|
183
183
|
In case of an exception, the error will be logger and re-thrown:
|
@@ -198,10 +198,10 @@ end
|
|
198
198
|
```
|
199
199
|
|
200
200
|
``` ruby
|
201
|
-
level
|
202
|
-
level
|
203
|
-
level
|
204
|
-
level
|
201
|
+
{"level":"INFO","time":"2017-12-12 09:41:27 +0000","pid":10950,"message":"user-registration-started","username":"shiroyasha"}
|
202
|
+
{"level":"INFO","time":"2017-12-12 09:41:27 +0000","pid":10950,"message":"User Record Created","username":"shiroyasha"}
|
203
|
+
{"level":"INFO","time":"2017-12-12 09:41:27 +0000","pid":10950,"message":"Sent signup email","username":"shiroyasha"}
|
204
|
+
{"level":"ERROR","time":"2017-12-12 09:41:27 +0000","pid":10950,"message":"Exception","username":"shiroyasha","type":"RuntimeError"}
|
205
205
|
```
|
206
206
|
|
207
207
|
## Development
|
data/lib/logman/version.rb
CHANGED
data/lib/logman.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "logman/version"
|
2
2
|
require "logger"
|
3
|
+
require "json"
|
3
4
|
|
4
5
|
# :reek:PrimaDonnaMethod { exclude: [clear! ] }
|
5
6
|
# :reek:TooManyStatements{ exclude: [process ] }
|
@@ -71,13 +72,13 @@ class Logman
|
|
71
72
|
private
|
72
73
|
|
73
74
|
def log(level, message, metadata = {})
|
74
|
-
@logger.public_send(level, { :
|
75
|
+
@logger.public_send(level, { :message => message }.merge(@fields).merge(metadata))
|
75
76
|
end
|
76
77
|
|
77
78
|
def formatter
|
78
79
|
proc do |severity, datetime, _progname, msg|
|
79
80
|
event = {
|
80
|
-
:level => severity
|
81
|
+
:level => severity.upcase,
|
81
82
|
:time => datetime,
|
82
83
|
:pid => Process.pid
|
83
84
|
}.merge(msg)
|
@@ -87,6 +88,6 @@ class Logman
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def format(event_hash)
|
90
|
-
event_hash.
|
91
|
+
event_hash.to_json
|
91
92
|
end
|
92
93
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rt-logman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rendered Text
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
166
|
rubyforge_project:
|
167
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.6.14
|
168
168
|
signing_key:
|
169
169
|
specification_version: 4
|
170
170
|
summary: Logman, formalized logging micro-abstraction
|