elastic-logger 0.3.0 → 0.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 872c5fac4c442800edc5f50ba4a90b2bd586a8ed
4
- data.tar.gz: 0fb77f04d8fdcd14e26e5e8fd7063166468a1153
3
+ metadata.gz: 7e5c23a7384acfb6540c80fe79f111d900c014b6
4
+ data.tar.gz: 9fcc4baf767189184765b585f2a0088293ec0942
5
5
  SHA512:
6
- metadata.gz: 5cca893d60d8fd8a4fe85568d10a1bdbecf7893981fd3d217667729cb5fbaa1bae8a6db5445e292c16f72ff1225728f4e062cf9dbe624ada248bedcf409fedd8
7
- data.tar.gz: 0a99de0fcaf25d3412da977d41ee6a1d225ceccc1723945ac3082c2a2f14bc3a198cfccd531a392a67153e7a97f24ebf8d5f95798a3dbf05b36b8d40c060bc55
6
+ metadata.gz: 33ad674a50f30e2d3e8afa558c495935ef0a399993f252c32e9a53709b57cab99a992cc27c5439fb45e6eaddedaead6a47f6a626a84f51ee0825fcc1829a248b
7
+ data.tar.gz: 1979f51570eab184e2e4fa78a5bda96ea631fc2770ff9881022b430fa0708763109ecfb807e2cfa8f48d97d5400404161f0ac2256968aa33d314113aa8683762
@@ -8,18 +8,29 @@ module ElasticLogger
8
8
  end
9
9
 
10
10
  def log(hash)
11
- client.index(index: index, type: name, body: hash)
11
+ client.index(index: index, type: name, body: build_log(hash))
12
12
  end
13
13
 
14
14
  private
15
15
  attr_reader :config, :name
16
16
 
17
+ def build_log(hash)
18
+ {
19
+ "@fields" => hash,
20
+ "@timestamp" => timestamp.iso8601(3)
21
+ }
22
+ end
23
+
17
24
  def client
18
25
  @client ||= Elasticsearch::Client.new(host: config.host)
19
26
  end
20
27
 
21
28
  def index
22
- "#{name}-#{Date.today.strftime('%Y.%m.%d')}"
29
+ "#{name}-#{timestamp.strftime('%Y.%m.%d')}"
30
+ end
31
+
32
+ def timestamp
33
+ Time.now.utc
23
34
  end
24
35
  end
25
36
  end
@@ -1,3 +1,3 @@
1
1
  module ElasticLogger
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastic-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Radosław Woźnik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-10-26 00:00:00.000000000 Z
12
+ date: 2017-10-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler