act-fluent-logger-rails 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +5 -1
- data/README.md +4 -0
- data/act-fluent-logger-rails.gemspec +1 -1
- data/lib/act-fluent-logger-rails/logger.rb +20 -1
- data/lib/act-fluent-logger-rails/version.rb +1 -1
- data/spec/logger_spec.rb +12 -0
- metadata +12 -7
- data/.ruby-version +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05832e487b4b706c45c60c718b8af8df70727b3e
|
4
|
+
data.tar.gz: d8060a8d22b973a64f2f88deb36e94bb32a2f165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 852f2e62bb26f23d128cf7bb85827561c2e51828a7029e1b05ec77d79bbcaf57fabdf188026b0c917708ab7ab412fcf71283c439e6448631f0a988f2de1f7cc3
|
7
|
+
data.tar.gz: 4b2e65c18ba75b62cfbd9d06ab1bab3ff958d306e618d08d7c3dc2bcc8ae96f24ede8f249266c833c9b6c398922ffdf4928c4ee7737a11026041c9e888d0b3e1
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -54,6 +54,10 @@ create config/fluent-logger.yml
|
|
54
54
|
tag: 'foo'
|
55
55
|
messages_type: 'string'
|
56
56
|
|
57
|
+
or set an environment variable FLUENTD_URL
|
58
|
+
|
59
|
+
http://fluentd.example.com:42442/foo?messages_type=string
|
60
|
+
|
57
61
|
* fluent_host: The host name of Fluentd.
|
58
62
|
* fluent_port: The port number of Fluentd.
|
59
63
|
* tag: The tag of the Fluentd event.
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'fluent-logger'
|
3
|
+
require 'active_support/core_ext'
|
4
|
+
require 'uri'
|
5
|
+
require 'cgi'
|
3
6
|
|
4
7
|
module ActFluentLoggerRails
|
5
8
|
|
@@ -10,7 +13,11 @@ module ActFluentLoggerRails
|
|
10
13
|
|
11
14
|
def self.new(config_file: Rails.root.join("config", "fluent-logger.yml"), log_tags: {})
|
12
15
|
Rails.application.config.log_tags = [ ->(request) { request } ] unless log_tags.empty?
|
13
|
-
fluent_config =
|
16
|
+
fluent_config = if ENV["FLUENTD_URL"]
|
17
|
+
self.parse_url(ENV["FLUENTD_URL"])
|
18
|
+
else
|
19
|
+
YAML.load(ERB.new(config_file.read).result)[Rails.env]
|
20
|
+
end
|
14
21
|
settings = {
|
15
22
|
tag: fluent_config['tag'],
|
16
23
|
host: fluent_config['fluent_host'],
|
@@ -23,6 +30,18 @@ module ActFluentLoggerRails
|
|
23
30
|
logger.extend self
|
24
31
|
end
|
25
32
|
|
33
|
+
def self.parse_url(fluentd_url)
|
34
|
+
uri = URI.parse fluentd_url
|
35
|
+
params = CGI.parse uri.query
|
36
|
+
|
37
|
+
{
|
38
|
+
host: uri.host,
|
39
|
+
port: uri.port,
|
40
|
+
tag: uri.path[1..-1],
|
41
|
+
messages_type: params["messages_type"].try(:first)
|
42
|
+
}.stringify_keys
|
43
|
+
end
|
44
|
+
|
26
45
|
def tagged(*tags)
|
27
46
|
@request = tags[0][0]
|
28
47
|
yield self
|
data/spec/logger_spec.rb
CHANGED
@@ -64,4 +64,16 @@ EOF
|
|
64
64
|
foo: 'foo_value'
|
65
65
|
} ]])
|
66
66
|
end
|
67
|
+
|
68
|
+
describe "use ENV['FLUENTD_URL']" do
|
69
|
+
let(:fluentd_url) { "http://fluentd.example.com:42442/hoge?messages_type=string" }
|
70
|
+
|
71
|
+
describe ".parse_url" do
|
72
|
+
subject { described_class.parse_url(fluentd_url) }
|
73
|
+
it { expect(subject['tag']).to eq 'hoge' }
|
74
|
+
it { expect(subject['host']).to eq 'fluentd.example.com' }
|
75
|
+
it { expect(subject['port']).to eq 42442 }
|
76
|
+
it { expect(subject['messages_type']).to eq 'string' }
|
77
|
+
end
|
78
|
+
end
|
67
79
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: act-fluent-logger-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TAHARA Yoshinori
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -42,16 +42,22 @@ dependencies:
|
|
42
42
|
name: rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.2.0
|
48
|
+
- - "<"
|
46
49
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
50
|
+
version: '5.0'
|
48
51
|
type: :runtime
|
49
52
|
prerelease: false
|
50
53
|
version_requirements: !ruby/object:Gem::Requirement
|
51
54
|
requirements:
|
52
|
-
- - "
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 3.2.0
|
58
|
+
- - "<"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
60
|
+
version: '5.0'
|
55
61
|
description: Fluent logger
|
56
62
|
email:
|
57
63
|
- read.eval.print@gmail.com
|
@@ -60,7 +66,6 @@ extensions: []
|
|
60
66
|
extra_rdoc_files: []
|
61
67
|
files:
|
62
68
|
- ".gitignore"
|
63
|
-
- ".ruby-version"
|
64
69
|
- CHANGELOG.md
|
65
70
|
- Gemfile
|
66
71
|
- LICENSE.txt
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.0.0-p195
|