rt-logman 0.12.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +10 -10
- data/lib/logman/version.rb +1 -1
- data/lib/logman.rb +2 -2
- 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: 15be3c449a0a876ee2386230fcdb4fd90ba33f6c
|
4
|
+
data.tar.gz: 65c355865f197a0446896ebe0ff4150f49169ffd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bddcf0c092468aa3fa249e35c31931a915ca385a2bcfad23f2f74e0ae89878fae744c1f712b0d7793bb7c0cac1ea20d0cf28eba06d244ec4e95b1ad74e4943e7
|
7
|
+
data.tar.gz: b4fcc9e9efd41039f699326c24ff2410630b6ba37cea218783872255f7825751acd6069a7ea0f9ead3810894bafce98693efe44644eab6ef082b3d87c2e06d57
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -62,7 +62,7 @@ FATAL > ERROR > WARN > INFO > DEBUG
|
|
62
62
|
## Instantiated Loggers
|
63
63
|
|
64
64
|
Logs in a class or system component usually share common metadata fields. For
|
65
|
-
this purpose,
|
65
|
+
this purpose, a new instance of Logman can be created and pre-populated with
|
66
66
|
metadata.
|
67
67
|
|
68
68
|
In the following example, we will add logs to a video processor:
|
@@ -74,7 +74,7 @@ class VideoProcessor
|
|
74
74
|
@logger = Logman.new
|
75
75
|
|
76
76
|
# these fields will appear in every log event
|
77
|
-
@logger.add(:
|
77
|
+
@logger.add(:component => "video_processor")
|
78
78
|
@logger.add(:id => @video.id)
|
79
79
|
@logger.add(:title => "Keyboard Cat")
|
80
80
|
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":"INFO","time":"2017-12-12 09:35:19 +0000","pid":10950,"message":"started","
|
110
|
-
{"level":"INFO","time":"2017-12-12 09:35:34 +0000","pid":10950,"message":"loaded into memory","
|
111
|
-
{"level":"INFO","time":"2017-12-12 09:35:44 +0000","pid":10950,"message":"compressed","
|
112
|
-
{"level":"INFO","time":"2017-12-12 09:36:08 +0000","pid":10950,"message":"uploaded to S3","
|
113
|
-
{"level":"INFO","time":"2017-12-12 09:36:27 +0000","pid":10950,"message":"finished","
|
109
|
+
{"level":"INFO","time":"2017-12-12 09:35:19 +0000","pid":10950,"message":"started","component":"video_processor","id":9312,"title":"Keyboard Cat"}
|
110
|
+
{"level":"INFO","time":"2017-12-12 09:35:34 +0000","pid":10950,"message":"loaded into memory","component":"video_processor","id":9312,"title":"Keyboard Cat","size":41241241}
|
111
|
+
{"level":"INFO","time":"2017-12-12 09:35:44 +0000","pid":10950,"message":"compressed","component":"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","component":"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","component":"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":"INFO","time":"2017-12-12 09:35:19 +0000","pid":10950,"message":"started","
|
120
|
-
{"level":"ERROR","time":"2017-12-12 09:35:34 +0000","pid":10950,"message":"failed","
|
119
|
+
{"level":"INFO","time":"2017-12-12 09:35:19 +0000","pid":10950,"message":"started","component":"video_processor","id":9312,"title":"Keyboard Cat"}
|
120
|
+
{"level":"ERROR","time":"2017-12-12 09:35:34 +0000","pid":10950,"message":"failed","component":"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)
|
@@ -180,7 +180,7 @@ The above will log the following information:
|
|
180
180
|
{"level":"INFO","time":"2017-12-12 09:40:39 +0000","pid":10950,"message":"user-registration-finished","username":"shiroyasha"}
|
181
181
|
```
|
182
182
|
|
183
|
-
In case of an exception, the error will be
|
183
|
+
In case of an exception, the error will be logged and re-thrown:
|
184
184
|
|
185
185
|
``` ruby
|
186
186
|
Logman.process("user-registration", :username => "shiroyasha") do |logger|
|
data/lib/logman/version.rb
CHANGED
data/lib/logman.rb
CHANGED
@@ -67,14 +67,14 @@ class Logman
|
|
67
67
|
|
68
68
|
result
|
69
69
|
rescue StandardError => exception
|
70
|
-
logger.error("#{name}-failed", :type => exception.class.name, :
|
70
|
+
logger.error("#{name}-failed", :type => exception.class.name, :msg => exception.message)
|
71
71
|
raise
|
72
72
|
end
|
73
73
|
|
74
74
|
private
|
75
75
|
|
76
76
|
def log(level, message, metadata = {})
|
77
|
-
@logger.public_send(level, { :
|
77
|
+
@logger.public_send(level, { :msg => message }.merge(@fields).merge(metadata))
|
78
78
|
end
|
79
79
|
|
80
80
|
def formatter
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rt-logman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rendered Text
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|