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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 382b857b60708db6ced95368595c63fa63bc291a
4
- data.tar.gz: 7f2c0caf20ee49f6f8000b83e800487f4e45ea3d
3
+ metadata.gz: 05832e487b4b706c45c60c718b8af8df70727b3e
4
+ data.tar.gz: d8060a8d22b973a64f2f88deb36e94bb32a2f165
5
5
  SHA512:
6
- metadata.gz: e5333ee6ae4aab328703c8c830561f7bca082d2659b03811a4b336a1069d9f9eaaf13bba02b0f1528ee9f1ebf4c754435dc34ce2fc468da6241269f311a183df
7
- data.tar.gz: 60d510bc4309db8eb01b70ac0d8b8ee27f5c5dbfc212f1c5ebff61ce94230204e009a7c16e09d98e5b92c5164f48d5309a4033ffe41ddd39d5008c0d236072cf
6
+ metadata.gz: 852f2e62bb26f23d128cf7bb85827561c2e51828a7029e1b05ec77d79bbcaf57fabdf188026b0c917708ab7ab412fcf71283c439e6448631f0a988f2de1f7cc3
7
+ data.tar.gz: 4b2e65c18ba75b62cfbd9d06ab1bab3ff958d306e618d08d7c3dc2bcc8ae96f24ede8f249266c833c9b6c398922ffdf4928c4ee7737a11026041c9e888d0b3e1
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ spec/reports
17
17
  test/tmp
18
18
  test/version_tmp
19
19
  tmp
20
+ .ruby-version
@@ -1,4 +1,8 @@
1
- ## 0.1.3 / April 11 2013
1
+ ## 0.1.4 / July 18 2014
2
+
3
+ * Enable to use EVN['FLUENTD_URL']
4
+
5
+ ## 0.1.3 / April 11 2014
2
6
 
3
7
  * Rails 4.1.0
4
8
 
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.
@@ -20,5 +20,5 @@ Gem::Specification.new do |gem|
20
20
 
21
21
  gem.add_development_dependency "rspec"
22
22
  gem.add_runtime_dependency "fluent-logger"
23
- gem.add_runtime_dependency "rails", "~> 4.1.0"
23
+ gem.add_runtime_dependency "rails", ">= 3.2.0", "< 5.0"
24
24
  end
@@ -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 = YAML.load(ERB.new(config_file.read).result)[Rails.env]
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
@@ -1,3 +1,3 @@
1
1
  module ActFluentLoggerRails
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -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.3
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-04-11 00:00:00.000000000 Z
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: 4.1.0
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: 4.1.0
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
@@ -1 +0,0 @@
1
- 2.0.0-p195