awesome_fluent_logger 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +8 -21
- data/.github/workflows/release.yml +2 -2
- data/CHANGELOG.md +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +58 -6
- data/lib/awesome_fluent_logger.rb +2 -2
- data/lib/awesome_fluent_logger/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2f2060607f90e202c8a113ffa5f912e7d3043d8f6a4daac4bb7cdc92d5f471c
|
4
|
+
data.tar.gz: 26e74d65295d1759338dba1ef7943a964c7cad12fb9f354e7d18256c3e0f4666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acab544566c8a34ff28319f6bb2d4c720291b3538d4b5b43b9e4c0164082faaefea0bab104740043b06c29908f5ec70d6bb246e1878f36f5bef5f91195999e63
|
7
|
+
data.tar.gz: 385cdb68c5c833f22154cd6efde8e8bd2949eaf9c502ac35343a899e43589865b88f61816f6b45129ce992f25b1260267f04e6a7ef036bf74ae16f977834fb39
|
data/.github/workflows/ci.yml
CHANGED
@@ -8,35 +8,22 @@ jobs:
|
|
8
8
|
rspec:
|
9
9
|
runs-on: ubuntu-latest
|
10
10
|
strategy:
|
11
|
-
fail-fast:
|
11
|
+
fail-fast: false
|
12
12
|
matrix:
|
13
13
|
ruby-version:
|
14
|
-
- 2.5
|
15
|
-
- 2.6
|
16
|
-
- 2.7
|
14
|
+
- "2.5"
|
15
|
+
- "2.6"
|
16
|
+
- "2.7"
|
17
|
+
- "3.0"
|
17
18
|
|
18
19
|
steps:
|
19
20
|
- uses: actions/checkout@v2
|
20
21
|
|
21
|
-
- uses: actions/cache@v1
|
22
|
-
with:
|
23
|
-
path: vendor/bundle
|
24
|
-
key: ${{ runner.os }}-gems-${{ hashFiles('api/Gemfile.lock') }}
|
25
|
-
restore-keys: |
|
26
|
-
${{ runner.os }}-gems-
|
27
|
-
|
28
22
|
- name: Setup Ruby v${{ matrix.ruby-version }}
|
29
|
-
uses:
|
23
|
+
uses: ruby/setup-ruby@v1
|
30
24
|
with:
|
31
|
-
|
32
|
-
|
33
|
-
- name: Install bundler
|
34
|
-
run: gem install bundler -v "~> 1.17"
|
35
|
-
|
36
|
-
- name: Execute bundle install
|
37
|
-
run: |
|
38
|
-
bundle config path vendor/bundle
|
39
|
-
bundle install --jobs 4 --retry 3
|
25
|
+
ruby-version: ${{ matrix.ruby-version }}
|
26
|
+
bundler-cache: true
|
40
27
|
|
41
28
|
- name: Run rspec
|
42
29
|
run: bundle exec rspec --format documentation
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# AwesomeFluentLogger
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/awesome_fluent_logger.svg?color=orange&logo=rubygems)](https://rubygems.org/gems/awesome_fluent_logger)
|
4
|
+
![ci](https://github.com/windyakin/awesome_fluent_logger/workflows/ci/badge.svg)
|
5
|
+
|
6
|
+
This library can mimic Ruby's built-in Logger class to forward logs to Fluentd. You can use this library not only for Rails but also for pure-Ruby apps.
|
7
|
+
|
8
|
+
Commentary: [シンプルに Fluentd にログ転送ができる RubyGem "awesome_fluent_logger" をつくった](https://windyakin.hateblo.jp/entry/2021/01/24/143242) (日本語/Japanese)
|
4
9
|
|
5
10
|
## Installation
|
6
11
|
|
@@ -47,18 +52,65 @@ Rails configure file (`config/application.rb` or `config/environments/{RAILS_ENV
|
|
47
52
|
|
48
53
|
```ruby
|
49
54
|
logger = AwesomeFluentLogger.new(fluent: { host: 'localhost', port: 24224 })
|
50
|
-
config.logger = ActiveSupport::TaggedLogging(logger)
|
55
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
51
56
|
```
|
52
57
|
|
53
|
-
###
|
58
|
+
### Can be set fluent-logger instance in initialize parameters
|
54
59
|
|
55
|
-
|
60
|
+
`:fluent` of initialize argument can be set an instance of [Fluent::Logger::FluentLogger](https://github.com/fluent/fluent-logger-ruby) class.
|
56
61
|
|
57
62
|
```ruby
|
58
|
-
fluent = Fluent::Logger.new(nil,
|
63
|
+
fluent = Fluent::Logger::FluentLogger.new(nil, socket_path: '/tmp/fluent.sock')
|
59
64
|
logger = AwesomeFluentLogger.new(fluent: fluent)
|
60
65
|
```
|
61
66
|
|
67
|
+
### Fluent tags
|
68
|
+
|
69
|
+
If the initialize parameter `[:fluent][:tag_prefix]` is specified, it will be inserted at the beginning of the Fluentd tag.
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
logger = AwesomeFluentLogger.new(fluent: { tag_prefix: 'kanan', host: 'localhost', port: 24224 })
|
73
|
+
logger.info('ご機嫌いかがかなん?')
|
74
|
+
```
|
75
|
+
|
76
|
+
```
|
77
|
+
2021-01-23 13:28:46.000000000 +0000 kanan.info: {"severity":"INFO", ...
|
78
|
+
```
|
79
|
+
|
80
|
+
The same effect is given by specifying `progname`.
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
logger = AwesomeFluentLogger.new(fluent: { host: 'localhost', port: 24224 }, progname: 'chika')
|
84
|
+
logger.info('かんかんみかん')
|
85
|
+
```
|
86
|
+
|
87
|
+
```
|
88
|
+
2021-01-23 13:28:46.000000000 +0000 chika.info: {"severity":"INFO", ...
|
89
|
+
```
|
90
|
+
|
91
|
+
If both are specified, they will be nested. In this case, tag_prefix will be added first.
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
logger = AwesomeFluentLogger.new(fluent: { tag_prefix: 'kanan', host: 'localhost', port: 24224 }, progname: 'chika')
|
95
|
+
logger.info('2人は幼馴染です')
|
96
|
+
```
|
97
|
+
|
98
|
+
```
|
99
|
+
2021-01-23 13:28:46.000000000 +0000 kanan.chika.info: {"severity":"INFO", ...
|
100
|
+
```
|
101
|
+
|
102
|
+
### Initialize parameters
|
103
|
+
|
104
|
+
Other initialization parameters are based on the Logger class of the Ruby standard library.
|
105
|
+
|
106
|
+
| Key | Default | Descriptions |
|
107
|
+
|:---|:---|:---|
|
108
|
+
| `fluent` | (none) | `Fluent::Logger::FluentLogger` initialize paramater hash or `Fluent::Logger::FluentLogger` class instance |
|
109
|
+
| `level` | `Logger::DEBUG` | [Logger severity level constant](https://docs.ruby-lang.org/en/master/Logger.html) |
|
110
|
+
| `progname` | `nil` | Program name to include in log messages **and Fluentd tag** |
|
111
|
+
| `formatter` | [`AwesomeFluentLogger::Formatter`](lib/awesome_fluent_logger/formatter.rb) | Inherited `Logger::Formatter` class instance |
|
112
|
+
| `datetime_format` | `%Y-%m-%d %H:%M:%S.%6N %z` | `%iso8601` or [`Time#strftime` formatted text](https://docs.ruby-lang.org/en/master/Time.html#method-i-strftime) |
|
113
|
+
|
62
114
|
## Contributing
|
63
115
|
|
64
116
|
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/awesome_fluent_logger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/awesome_fluent_logger/blob/master/CODE_OF_CONDUCT.md).
|
@@ -66,4 +118,4 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
66
118
|
|
67
119
|
## License
|
68
120
|
|
69
|
-
|
121
|
+
[MIT License](LICENSE.txt)
|
@@ -3,8 +3,8 @@ require 'awesome_fluent_logger/logger'
|
|
3
3
|
require 'awesome_fluent_logger/formatter'
|
4
4
|
|
5
5
|
module AwesomeFluentLogger
|
6
|
-
def self.new(
|
7
|
-
AwesomeFluentLogger::Logger.new(
|
6
|
+
def self.new(**args)
|
7
|
+
AwesomeFluentLogger::Logger.new(**args)
|
8
8
|
end
|
9
9
|
class FluentConnectionError < StandardError; end
|
10
10
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awesome_fluent_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- windyakin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluent-logger
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- ".github/workflows/release.yml"
|
80
80
|
- ".gitignore"
|
81
81
|
- ".rspec"
|
82
|
+
- CHANGELOG.md
|
82
83
|
- CODE_OF_CONDUCT.md
|
83
84
|
- Gemfile
|
84
85
|
- Gemfile.lock
|
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
116
|
- !ruby/object:Gem::Version
|
116
117
|
version: '0'
|
117
118
|
requirements: []
|
118
|
-
rubygems_version: 3.1.
|
119
|
+
rubygems_version: 3.1.4
|
119
120
|
signing_key:
|
120
121
|
specification_version: 4
|
121
122
|
summary: Awesome logger with fluent-logger for Ruby
|