ecs-logging 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 43b9e37dc57c2eadf7ea3e27ba6ee4060d94e814dc4921e1262702927b9a8a12
4
- data.tar.gz: a255a92fc7cf973b266ecc8e8eec64f599cba52c45b033c15920280ef590fd2d
3
+ metadata.gz: 1915b7e8e0bb7478ec5f730ab0362392f09f820ac12d79fd3474f87e207a05a3
4
+ data.tar.gz: e4100217b49ec650f2594176976f8f452a64cf26e7b807b99e1baca6fc47cbb0
5
5
  SHA512:
6
- metadata.gz: 0d47468fc499ebd03c1335a55a2d7c4f0b0dac14a92865d6a847c9c7dc10035ba067ae2c5c9a5469545483dc62d4f3f0429ac2232bbf054a64e97da258f87863
7
- data.tar.gz: 37353532f52a56192916c791871eed288b57001a44df012f2a582cfb06f78c3dbe535f0fe478071e0a7dded74896679163f9d5b8388d7709e0504578b1cda7ef
6
+ metadata.gz: 27e97608af308c9efed7211c0a50cef1f9832a6aa57ac4eb4c80d01d25d9b3cd28b3a01fb73cbbb88ee9a314ffa5c5cc45bdd8eddd645d7752741f21d10f43ed
7
+ data.tar.gz: 15abf89d399284aaad1517508358a8a5b34da28bdf1b442164be2f905a790eaa44b49978c7ab7285024e50b3c035e9f155b846da6acb85e5dea6b39a9042042e
@@ -46,11 +46,11 @@ pipeline {
46
46
  axes {
47
47
  axis {
48
48
  name 'RUBY_VERSION'
49
- values 'ruby:2.7', 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2', 'jruby:9.1'
49
+ values 'ruby:2.7', 'ruby:2.6', 'ruby:2.5', 'ruby:2.4', 'ruby:2.3', 'jruby:9.2'
50
50
  }
51
51
  axis {
52
52
  name 'FRAMEWORK'
53
- values 'rails-6.0', 'rails-5.2', 'rails-5.1', 'sinatra-2.0'
53
+ values 'rails-6.1', 'rails-6.0', 'rails-5.2', 'sinatra-2.0'
54
54
  }
55
55
  }
56
56
  stages {
data/.gitignore CHANGED
@@ -16,3 +16,6 @@ Gemfile.lock
16
16
 
17
17
  # junit reports folder
18
18
  spec/junit-reports
19
+
20
+ # Doc build files
21
+ html_docs
@@ -35,6 +35,13 @@ endif::[]
35
35
  [[release-notes-0.x]]
36
36
  === ECS logging Ruby 0.x
37
37
 
38
+ [[release-notes-0.2.1]]
39
+ ==== 0.2.1 (2021-01-13)
40
+
41
+ ===== Fixed
42
+
43
+ - Calling severity methods without a progname {pull}13[#13]
44
+
38
45
  [[release-notes-0.2.0]]
39
46
  ==== 0.2.0 (2020-12-09)
40
47
 
data/Dockerfile CHANGED
@@ -34,7 +34,7 @@ RUN gem update --system && \
34
34
  gem install bundler:$BUNDLER_VERSION
35
35
 
36
36
  # Use unpatched, system version for more speed over less security
37
- RUN gem install nokogiri -- --use-system-libraries
37
+ RUN gem install nokogiri -v 1.10.10 -- --use-system-libraries
38
38
 
39
39
  WORKDIR /app
40
40
 
data/README.md CHANGED
@@ -10,115 +10,9 @@ See [ecs-logging](https://github.com/elastic/ecs-logging) for other ECS logging
10
10
 
11
11
  **Please note** that this library is in a <strong>pre-1.0</strong> version and backwards-incompatible changes might be introduced in future releases. While we strive to comply to [semver](https://semver.org/), we can not guarantee to avoid breaking changes in minor releases.
12
12
 
13
- ## Installation
13
+ ## Documentation
14
14
 
15
- Add this line to your application's Gemfile:
16
-
17
- ```ruby
18
- gem 'ecs-logging'
19
- ```
20
-
21
- And then execute:
22
-
23
- $ bundle install
24
-
25
- Or install it yourself as:
26
-
27
- $ gem install ecs-logging
28
-
29
- ## Usage
30
-
31
- `Ecs::Logger` is a subclass of Ruby's own [`Logger`](https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html) and responds to the same methods.
32
-
33
- ```ruby
34
- require 'ecs/logger'
35
-
36
- logger = Ecs::Logger.new($stdout)
37
- logger.info('my informative message')
38
- logger.warn { 'be aware that…' }
39
- logger.error('a_progname') { 'oh no!' }
40
- ```
41
-
42
- Logs the following JSON to `$stdout`:
43
-
44
- ```ndjson
45
- {"@timestamp":"2020-11-24T13:32:21.329Z","log.level":"INFO","message":"very informative","ecs.version":"1.4.0"}
46
- {"@timestamp":"2020-11-24T13:32:21.330Z","log.level":"WARN","message":"be aware that…","ecs.version":"1.4.0"}
47
- {"@timestamp":"2020-11-24T13:32:21.331Z","log.level":"ERROR","message":"oh no!","ecs.version":"1.4.0","process.title":"a_progname"}
48
- ```
49
-
50
- Additionally, it allows for adding additional keys to messages, eg:
51
-
52
- ```ruby
53
- logger.info('ok', labels: { my_label: 'value' }, 'trace.id': 'abc-xyz')
54
- ```
55
-
56
- Logs:
57
-
58
- ```json
59
- {
60
- "@timestamp":"2020-11-24T13:32:21.331Z",
61
- "log.level":"ERROR",
62
- "message":"oh no!",
63
- "ecs.version":"1.4.0",
64
- "labels":{"my_label":"value"},
65
- "trace.id":"abc-xyz"
66
- }
67
- ```
68
-
69
- To include info about where the log was called, call the methods with `include_origin: true`, like:
70
-
71
- ```ruby
72
- logger.warn('Hello!', include_origin: true)
73
- ```
74
-
75
- Resulting in
76
-
77
- ```json
78
- {
79
- "@timestamp":"2020-11-24T13:32:21.331Z",
80
- "log.level":"WARN",
81
- "message":"Hello!",
82
- "ecs.version":"1.4.0",
83
- "log.origin": {
84
- "file.line": 123,
85
- "file.name": "my_file.rb",
86
- "function": "call"
87
- }
88
- }
89
- ```
90
-
91
- ## Usage with Rack
92
-
93
- ```ruby
94
- use EcsLogging::Middleware, $stdout
95
- ```
96
-
97
- Example output:
98
-
99
- ```json
100
- {
101
- "@timestamp":"2020-12-07T13:44:04.568Z",
102
- "log.level":"INFO",
103
- "message":"GET /",
104
- "ecs.version":"1.4.0",
105
- "client":{
106
- "address":"127.0.0.1"
107
- },
108
- "http":{
109
- "request":{
110
- "method":"GET",
111
- "body.bytes":"0"
112
- }
113
- },
114
- "url":{
115
- "domain":"example.org",
116
- "path":"/",
117
- "port":"80",
118
- "scheme":"http"
119
- }
120
- }
121
- ```
15
+ Ready to get started? Documentation is at [elastic.co](https://www.elastic.co/guide/en/ecs-logging/ruby/current/index.html).
122
16
 
123
17
  ## License
124
18
 
@@ -0,0 +1,16 @@
1
+ :ecs-repo-dir: {ecs-logging-root}/docs/
2
+
3
+ include::{docs-root}/shared/versions/stack/current.asciidoc[]
4
+ include::{docs-root}/shared/attributes.asciidoc[]
5
+
6
+ ifdef::env-github[]
7
+ NOTE: For the best reading experience,
8
+ please view this documentation at https://www.elastic.co/guide/en/ecs-logging/ruby/current/index.html[elastic.co]
9
+ endif::[]
10
+
11
+ = ECS Logging Ruby Reference
12
+
13
+ ifndef::env-github[]
14
+ include::./intro.asciidoc[Introduction]
15
+ include::./setup.asciidoc[Set up]
16
+ endif::[]
@@ -0,0 +1,10 @@
1
+ [[intro]]
2
+ == Introduction
3
+
4
+ ECS loggers are formatter/encoder plugins for your favorite logging libraries.
5
+ They make it easy to format your logs into ECS-compatible JSON.
6
+
7
+ TIP: Want to learn more about ECS, ECS logging, and other available language plugins?
8
+ See the {ecs-logging-ref}/intro.html[ECS logging guide].
9
+
10
+ Ready to jump into `ecs-logging-ruby`? <<setup,Get started>>.
@@ -0,0 +1,145 @@
1
+ [[setup]]
2
+ == Get started
3
+
4
+ [float]
5
+ [[setup-step-1]]
6
+ === Step 1: Set up application logging
7
+
8
+ [float]
9
+ ==== Add the dependency
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ [source,ruby]
14
+ ----
15
+ gem 'ecs-logging'
16
+ ----
17
+
18
+ Execute with:
19
+
20
+ [source,cmd]
21
+ ----
22
+ bundle install
23
+ ----
24
+
25
+ Alternatively, you can install the package yourself with:
26
+
27
+ [source,cmd]
28
+ ----
29
+ gem install ecs-logging
30
+ ----
31
+
32
+ [float]
33
+ ==== Configure
34
+
35
+ `Ecs::Logger` is a subclass of Ruby's own https://ruby-doc.org/stdlib/libdoc/logger/rdoc/Logger.html[`Logger`]
36
+ and responds to the same methods.
37
+
38
+ For example:
39
+
40
+ [source,ruby]
41
+ ----
42
+ require 'ecs_logging/logger'
43
+
44
+ logger = EcsLogging::Logger.new($stdout)
45
+ logger.info('my informative message')
46
+ logger.warn { 'be aware that…' }
47
+ logger.error('a_progname') { 'oh no!' }
48
+ ----
49
+
50
+ Logs the following JSON to `$stdout`:
51
+
52
+ [source,json]
53
+ ----
54
+ {"@timestamp":"2020-11-24T13:32:21.329Z","log.level":"INFO","message":"very informative","ecs.version":"1.4.0"}
55
+ {"@timestamp":"2020-11-24T13:32:21.330Z","log.level":"WARN","message":"be aware that…","ecs.version":"1.4.0"}
56
+ {"@timestamp":"2020-11-24T13:32:21.331Z","log.level":"ERROR","message":"oh no!","ecs.version":"1.4.0","process.title":"a_progname"}
57
+ ----
58
+
59
+ Additionally, it allows for adding additional keys to messages.
60
+
61
+ For example:
62
+
63
+ [source,ruby]
64
+ ----
65
+ logger.info('ok', labels: { my_label: 'value' }, 'trace.id': 'abc-xyz')
66
+ ----
67
+
68
+ Logs the following:
69
+
70
+ [source,json]
71
+ ----
72
+ {
73
+ "@timestamp":"2020-11-24T13:32:21.331Z",
74
+ "log.level":"ERROR",
75
+ "message":"oh no!",
76
+ "ecs.version":"1.4.0",
77
+ "labels":{"my_label":"value"},
78
+ "trace.id":"abc-xyz"
79
+ }
80
+ ----
81
+
82
+ To include info about where the log was called, call the methods with `include_origin: true`,
83
+ like `logger.warn('Hello!', include_origin: true)`. This logs:
84
+
85
+ [source,json]
86
+ ----
87
+ {
88
+ "@timestamp":"2020-11-24T13:32:21.331Z",
89
+ "log.level":"WARN",
90
+ "message":"Hello!",
91
+ "ecs.version":"1.4.0",
92
+ "log.origin": {
93
+ "file.line": 123,
94
+ "file.name": "my_file.rb",
95
+ "function": "call"
96
+ }
97
+ }
98
+ ----
99
+
100
+ [float]
101
+ ==== Rack configuration
102
+
103
+ [source,ruby]
104
+ ----
105
+ use EcsLogging::Middleware, $stdout
106
+ ----
107
+
108
+ Example output:
109
+
110
+ [source,json]
111
+ ----
112
+ {
113
+ "@timestamp":"2020-12-07T13:44:04.568Z",
114
+ "log.level":"INFO",
115
+ "message":"GET /",
116
+ "ecs.version":"1.4.0",
117
+ "client":{
118
+ "address":"127.0.0.1"
119
+ },
120
+ "http":{
121
+ "request":{
122
+ "method":"GET",
123
+ "body.bytes":"0"
124
+ }
125
+ },
126
+ "url":{
127
+ "domain":"example.org",
128
+ "path":"/",
129
+ "port":"80",
130
+ "scheme":"http"
131
+ }
132
+ }
133
+ ----
134
+
135
+ [float]
136
+ [[setup-step-2]]
137
+ === Step 2: Enable APM log correlation (optional)
138
+ If you are using the Elastic APM Ruby agent,
139
+ {apm-ruby-ref}/log-correlation.html[enable log correlation].
140
+
141
+ [float]
142
+ [[setup-step-3]]
143
+ === Step 3: Configure Filebeat
144
+
145
+ include::{ecs-repo-dir}/setup.asciidoc[tag=configure-filebeat]
@@ -57,7 +57,7 @@ module EcsLogging
57
57
  end
58
58
 
59
59
  %w[unknown fatal error warn info debug].each do |severity|
60
- define_method(severity) do |progname, include_origin: false, **extras, &block|
60
+ define_method(severity) do |progname = nil, include_origin: false, **extras, &block|
61
61
  if include_origin && origin = origin_from_caller(caller)
62
62
  extras[:"log.origin"] = origin
63
63
  end
@@ -18,5 +18,5 @@
18
18
  # frozen_string_literal: true
19
19
 
20
20
  module EcsLogging
21
- VERSION = "0.2.0"
21
+ VERSION = "0.2.1"
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecs-logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mikkel Malmberg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-09 00:00:00.000000000 Z
11
+ date: 2021-01-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Write a longer description or delete this line.
14
14
  email:
@@ -36,6 +36,9 @@ files:
36
36
  - bin/dev
37
37
  - docker-compose.yml
38
38
  - docker/entrypoint.sh
39
+ - docs/index.asciidoc
40
+ - docs/intro.asciidoc
41
+ - docs/setup.asciidoc
39
42
  - ecs-logging.gemspec
40
43
  - lib/ecs-logging.rb
41
44
  - lib/ecs_logging.rb