l2meter 0.5.1 → 0.6.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: 0eba3f8d968b76be9bc0f2a689128f1b391869bc
4
- data.tar.gz: c0b363f3509d4c439f6d1ad8263f34e6c3f75ccc
3
+ metadata.gz: 9ddd680884b093d7ef2d8f5d4dbdfa3ad58ff4ae
4
+ data.tar.gz: 387975331395c28b5e61dd8fcd6be445136cfc09
5
5
  SHA512:
6
- metadata.gz: a9c0063ccd821e4c1bd55b3649a69ebd87f311beb52531c5878c31d0d84d4f07efc321d76848b2dd3b2798116187cda9cc1438145f68c21ef74fdbecae8ac3e1
7
- data.tar.gz: 77d4006f64c61d65b833d19f5d986512aa35f92134a8cc3587aa23fa4d40b3d3d29de0db084b29aa5c4b7be177f9b479cb90314bbfc71658505cdce0f026ba9b
6
+ metadata.gz: b42d3ca0e240e09a0a486d6b6f71415f301abf6e2bae4e9ea80baa5b203b8d3378b4f0d3827b6577324533d6bb19682807989aedf050dccd3eb7988c07830d61
7
+ data.tar.gz: 86520c81cfed832b8fe638fe5cda97279294e8cb2de2e8e6a4ac183d709f210ff2f9a6356ceef8976a7b1c2279969dfff446f3d39e4bc71faaa55ba45a48723e
data/README.md CHANGED
@@ -85,6 +85,30 @@ def do_work_with_retries
85
85
  end
86
86
  ```
87
87
 
88
+ ## Contexted logging
89
+
90
+ Sometimes you want another copy of the logger with a specific context on it.
91
+ You can created one like so:
92
+
93
+ ```ruby
94
+ logger = Metrics.context(:super_worker, username: "joe")
95
+
96
+ SuperWorker.new(logger: logger).run # => super-worker username=joe some-other=superworker-output
97
+ ```
98
+
99
+ ## Batching
100
+
101
+ There's also a way to batch several calls into a single log line:
102
+
103
+ ```ruby
104
+ Metrics.batch do
105
+ Metrics.log foo: :bar
106
+ Metrics.unique :registeration, "user@example.com"
107
+ Metrics.count :thing, 10
108
+ Metrics.sample :other_thing, 20
109
+ end # => foo=bar unique#registration=user@example.com count#thing=10 sample#other-thing=20
110
+ ```
111
+
88
112
  ## Other
89
113
 
90
114
  Some other l2met-specific methods are supported.
@@ -113,17 +137,6 @@ Metrics.with_elapsed do
113
137
  end
114
138
  ```
115
139
 
116
- There's also a way to batch several calls into a single log line:
117
-
118
- ```ruby
119
- Metrics.batch do
120
- Metrics.log foo: :bar
121
- Metrics.unique :registeration, "user@example.com"
122
- Metrics.count :thing, 10
123
- Metrics.sample :other_thing, 20
124
- end # => foo=bar unique#registration=user@example.com count#thing=10 sample#other-thing=20
125
- ```
126
-
127
140
  ### Configuration
128
141
 
129
142
  L2meter supports configuration. Here's how you can configure things:
@@ -180,13 +180,14 @@ module L2meter
180
180
 
181
181
  def flush_buffer
182
182
  tokens = @buffer.map do |key, value|
183
+ next if value.nil?
183
184
  key = format_key(key)
184
185
  value == true ? key : "#{key}=#{format_value(value)}"
185
- end
186
+ end.compact
186
187
 
187
188
  tokens.sort! if configuration.sort?
188
189
 
189
- output_queue.last.puts [*tokens].join(" ")
190
+ output_queue.last.puts [*tokens].join(" ") if tokens.any?
190
191
  ensure
191
192
  @buffer.clear
192
193
  end
@@ -1,3 +1,3 @@
1
1
  module L2meter
2
- VERSION = "0.5.1".freeze
2
+ VERSION = "0.6.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: l2meter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Pravosud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-11 00:00:00.000000000 Z
11
+ date: 2016-04-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: