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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb547bfe89e346a9c9198e1fe5f49c536d8a81e8
4
- data.tar.gz: 6fd763746e3360aef85d2296002ecad1fbf28693
3
+ metadata.gz: 3532e63f6b57a4160f02ef0d59b85b66ebb8eff6
4
+ data.tar.gz: 728484d7773b6767795a6a1b1cb474fb55e6bab3
5
5
  SHA512:
6
- metadata.gz: c48037c426a5a926734a06cf3a9e0feaf40eb4752ae7a36e4847914f672374f46cdbd5f350cf5c9f09777c0d6e60f0a2def30e52e8edf9b3c7534ec8d00102fa
7
- data.tar.gz: 83ab488cf6dc57d35790134b385b9d6d7ff1ca860bc1f9c943863ed158f86e3710ce3e298c2d6b7404216b4df6421dab525d2d38f4a92b4543618cbdd14b02de
6
+ metadata.gz: 3c975db44a0a5d3721f2fc81267d45a4a7ba4c9e1a75841c0506ff5abdc29df2a51713a0654772d247c87f350e1a6c93cea47a82da7aad193856d5dc0c29e7fc
7
+ data.tar.gz: 5435f732788c988d6303a6c56783ccea9e09edb0251f64c04d3830098729a38c54a9446294fbedce1fc877602e8fa825ec255f3c468fdf7f817df11e0324225e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rt-logman (0.10.0)
4
+ rt-logman (0.11.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
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='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='Hello World'
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='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='Hello World' from='renderedtext' to='The World'
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='E' time='2017-12-11 09:47:27 +0000' pid='1234' event='Team does not exists' owner='renderedtext' team_name='z-fighters'
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", :message => exception.message)
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='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='started' id='31312' title='Keyboard Cat' component='video_processor'
110
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='loaded into memory' component='video_processor' id='31312' title='Keyboard Cat' size='3123131312'
111
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='compressed' component='video_processor' id='31312' title='Keyboard Cat' size='12312312'
112
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='upload_to_s3' component='video_processor' id='31312' title='Keyboard Cat' s3_path='s3://random'
113
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='finished' component='video_processor' id='31312' title='Keyboard Cat'
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='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='started' id='31312' title='Keyboard Cat' component='video_processor'
120
- level='E' time='2017-12-11 09:47:27 +0000' pid='1234' event='failed' component='video_processor' id='31312' title='Keyboard Cat' message='Out of memory'
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='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='Hello' version='v2'
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='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='user-registration-started' username='shiroyasha'
177
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='User Record Created' username='shiroyasha'
178
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='Sent signup email' username='shiroyasha'
179
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='Added user to a team' username='shiroyasha' team_id='312'
180
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='user-registration-finished' username='shiroyasha'
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='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='user-registration-started' username='shiroyasha'
202
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='User Record Created' username='shiroyasha'
203
- level='I' time='2017-12-11 09:47:27 +0000' pid='1234' event='Sent signup email' username='shiroyasha'
204
- level='E' time='2017-12-11 09:47:27 +0000' pid='1234' event='user-registration-failed' username='shiroyasha' type='RuntimeError' message='Exception'
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
@@ -1,3 +1,3 @@
1
1
  class Logman
2
- VERSION = "0.10.0".freeze
2
+ VERSION = "0.11.0".freeze
3
3
  end
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, { :event => message }.merge(@fields).merge(metadata))
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[0].upcase,
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.map { |key, value| "#{key}='#{value}'" }.join(" ")
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.10.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.5.2.1
167
+ rubygems_version: 2.6.14
168
168
  signing_key:
169
169
  specification_version: 4
170
170
  summary: Logman, formalized logging micro-abstraction