awesome_fluent_logger 0.1.0 → 1.0.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 +4 -4
- data/.editorconfig +12 -0
- data/.github/workflows/ci.yml +42 -0
- data/.github/workflows/release.yml +29 -0
- data/Gemfile.lock +1 -1
- data/README.md +37 -12
- data/awesome_fluent_logger.gemspec +1 -1
- data/lib/awesome_fluent_logger/formatter.rb +2 -6
- data/lib/awesome_fluent_logger/logger.rb +7 -3
- data/lib/awesome_fluent_logger/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1684e8418e704f1c67b8d2de819c643aaea45c519b5434238f2c212cff61dac5
|
4
|
+
data.tar.gz: 9392912355c358904c46de8321a4efeaae97a12a4ce80671f0544ba2eab6347e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2df0d2b0f0961670b964ea835a4d170bb19ad4a279e48a34d3731143c93f55d79a986e2ff06129ba2a8b31cf53a76b64fead02075b2b948ccc9b6a2fdbddedb
|
7
|
+
data.tar.gz: 40a62cd6d6e5cda5c7b5f166b7f58387a36a1b6b24e0f78c64e08ed4bde962ad234bbb1507bf5f7f1a6346d74dfb2ee30453a142d7493e05023051ede896c395
|
data/.editorconfig
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
name: ci
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
rspec:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
fail-fast: true
|
12
|
+
matrix:
|
13
|
+
ruby-version:
|
14
|
+
- 2.5
|
15
|
+
- 2.6
|
16
|
+
- 2.7
|
17
|
+
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
|
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
|
+
- name: Setup Ruby v${{ matrix.ruby-version }}
|
29
|
+
uses: actions/setup-ruby@v1
|
30
|
+
with:
|
31
|
+
ruby_version: ${{ matrix.ruby-version }}
|
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
|
40
|
+
|
41
|
+
- name: Run rspec
|
42
|
+
run: bundle exec rspec --format documentation
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: release
|
2
|
+
|
3
|
+
on:
|
4
|
+
release:
|
5
|
+
types:
|
6
|
+
- published
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
push:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
|
15
|
+
- name: Set up Ruby 2.6
|
16
|
+
uses: actions/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
- 2.6
|
19
|
+
|
20
|
+
- name: Publish to RubyGems
|
21
|
+
env:
|
22
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
23
|
+
run: |
|
24
|
+
mkdir -p $HOME/.gem
|
25
|
+
touch $HOME/.gem/credentials
|
26
|
+
chmod 0600 $HOME/.gem/credentials
|
27
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
28
|
+
gem build awesome_fluent_logger.gemspec
|
29
|
+
gem push *.gem
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/awesome_fluent_logger`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
4
|
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
6
|
-
|
7
5
|
## Installation
|
8
6
|
|
9
7
|
Add this line to your application's Gemfile:
|
@@ -14,21 +12,52 @@ gem 'awesome_fluent_logger'
|
|
14
12
|
|
15
13
|
And then execute:
|
16
14
|
|
17
|
-
|
15
|
+
```
|
16
|
+
$ bundle install
|
17
|
+
```
|
18
18
|
|
19
19
|
Or install it yourself as:
|
20
20
|
|
21
|
-
|
21
|
+
```
|
22
|
+
$ gem install awesome_fluent_logger
|
23
|
+
```
|
22
24
|
|
23
25
|
## Usage
|
24
26
|
|
25
|
-
|
27
|
+
### Tiny example
|
28
|
+
|
29
|
+
Your Ruby program:
|
26
30
|
|
27
|
-
|
31
|
+
```ruby
|
32
|
+
require 'awesome_fluent_logger'
|
33
|
+
|
34
|
+
logger = AwesomeFluentLogger.new(fluent: { host: 'localhost', port: 24224 })
|
35
|
+
logger.info('information logging')
|
36
|
+
```
|
28
37
|
|
29
|
-
|
38
|
+
Fluentd output:
|
39
|
+
|
40
|
+
```
|
41
|
+
2021-01-23 13:28:46.000000000 +0000 info: {"severity":"INFO","time":"2021-01-23 13:28:46.336397 +0000","progname":null,"message":"information logging"}
|
42
|
+
```
|
30
43
|
|
31
|
-
|
44
|
+
### Rails example
|
45
|
+
|
46
|
+
Rails configure file (`config/application.rb` or `config/environments/{RAILS_ENV}.rb`):
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
logger = AwesomeFluentLogger.new(fluent: { host: 'localhost', port: 24224 })
|
50
|
+
config.logger = ActiveSupport::TaggedLogging(logger)
|
51
|
+
```
|
52
|
+
|
53
|
+
### Set fluent-logger instance
|
54
|
+
|
55
|
+
`fluent` of initialize argument can be passed an instance of [fluent-logger](https://github.com/fluent/fluent-logger-ruby)
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
fluent = Fluent::Logger.new(nil, host: 'localhost', port: 24224)
|
59
|
+
logger = AwesomeFluentLogger.new(fluent: fluent)
|
60
|
+
```
|
32
61
|
|
33
62
|
## Contributing
|
34
63
|
|
@@ -38,7 +67,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
|
38
67
|
## License
|
39
68
|
|
40
69
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
41
|
-
|
42
|
-
## Code of Conduct
|
43
|
-
|
44
|
-
Everyone interacting in the AwesomeFluentLogger project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/awesome_fluent_logger/blob/master/CODE_OF_CONDUCT.md).
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
"You can use this library not only for Rails but also for pure-Ruby apps."
|
12
12
|
spec.homepage = "https://github.com/windyakin/awesome_fluent_logger"
|
13
13
|
spec.license = "MIT"
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.5.0")
|
15
15
|
|
16
16
|
spec.add_dependency 'fluent-logger', '~> 0.9'
|
17
17
|
|
@@ -14,17 +14,13 @@ module AwesomeFluentLogger
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def datetime_format=(format)
|
17
|
-
|
18
|
-
@datetime_format = '%Y-%m-%dT%H:%M:%S%:z'
|
19
|
-
else
|
20
|
-
@datetime_format = format
|
21
|
-
end
|
17
|
+
@datetime_format = format == '%iso8601' ? '%Y-%m-%dT%H:%M:%S%:z' : format
|
22
18
|
end
|
23
19
|
|
24
20
|
protected
|
25
21
|
|
26
22
|
def format_datetime(time)
|
27
|
-
time.strftime(@datetime_format ||
|
23
|
+
time.strftime(@datetime_format || '%Y-%m-%d %H:%M:%S.%6N %z')
|
28
24
|
end
|
29
25
|
end
|
30
26
|
end
|
@@ -10,7 +10,7 @@ module AwesomeFluentLogger
|
|
10
10
|
super(nil, 0, 0, level: level, progname: progname, formatter: formatter, datetime_format: datetime_format)
|
11
11
|
|
12
12
|
if fluent.is_a?(Hash)
|
13
|
-
tag_prefix = fluent.fetch(:tag_prefix,
|
13
|
+
tag_prefix = fluent.fetch(:tag_prefix, nil)
|
14
14
|
@logger = ::Fluent::Logger::FluentLogger.new(tag_prefix, **fluent)
|
15
15
|
elsif fluent.respond_to?(:post)
|
16
16
|
@logger = fluent
|
@@ -41,13 +41,17 @@ module AwesomeFluentLogger
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
44
|
+
formatted_severity = format_severity(severity)
|
45
|
+
|
46
|
+
data = format_message(formatted_severity, Time.now, progname, message)
|
45
47
|
|
46
48
|
unless data.is_a?(Hash)
|
47
49
|
data = {data: data}
|
48
50
|
end
|
49
51
|
|
50
|
-
|
52
|
+
tag = [progname&.+('.'), formatted_severity.downcase].join
|
53
|
+
|
54
|
+
@logger.post(tag, data)
|
51
55
|
true
|
52
56
|
end
|
53
57
|
|
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:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- windyakin
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-01-
|
11
|
+
date: 2021-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluent-logger
|
@@ -74,6 +74,9 @@ executables: []
|
|
74
74
|
extensions: []
|
75
75
|
extra_rdoc_files: []
|
76
76
|
files:
|
77
|
+
- ".editorconfig"
|
78
|
+
- ".github/workflows/ci.yml"
|
79
|
+
- ".github/workflows/release.yml"
|
77
80
|
- ".gitignore"
|
78
81
|
- ".rspec"
|
79
82
|
- CODE_OF_CONDUCT.md
|
@@ -97,7 +100,7 @@ metadata:
|
|
97
100
|
homepage_uri: https://github.com/windyakin/awesome_fluent_logger
|
98
101
|
source_code_uri: https://github.com/windyakin/awesome_fluent_logger
|
99
102
|
changelog_uri: https://github.com/windyakin/awesome_fluent_logger/blob/master/CHANGELOG.md
|
100
|
-
post_install_message:
|
103
|
+
post_install_message:
|
101
104
|
rdoc_options: []
|
102
105
|
require_paths:
|
103
106
|
- lib
|
@@ -105,16 +108,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
105
108
|
requirements:
|
106
109
|
- - ">="
|
107
110
|
- !ruby/object:Gem::Version
|
108
|
-
version: 2.
|
111
|
+
version: 2.5.0
|
109
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
113
|
requirements:
|
111
114
|
- - ">="
|
112
115
|
- !ruby/object:Gem::Version
|
113
116
|
version: '0'
|
114
117
|
requirements: []
|
115
|
-
|
116
|
-
|
117
|
-
signing_key:
|
118
|
+
rubygems_version: 3.1.2
|
119
|
+
signing_key:
|
118
120
|
specification_version: 4
|
119
121
|
summary: Awesome logger with fluent-logger for Ruby
|
120
122
|
test_files: []
|