act-fluent-logger-rails 0.0.3 → 0.0.4

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.
data/CHANGELOG.md ADDED
@@ -0,0 +1,4 @@
1
+ ## 0.0.4 / January 19 2013
2
+
3
+ * Add messages_type parameter to fluent-logger.yml to specifying
4
+ output messages type 'string' or 'array'. Thanks to davidrenne.
data/README.md CHANGED
@@ -26,19 +26,39 @@ in config/environments/production.rb
26
26
  create config/fluent-logger.yml
27
27
 
28
28
  development:
29
- fluent_host: '127.0.0.1'
30
- fluent_port: 24224
31
- tag: 'foo'
29
+ fluent_host: '127.0.0.1'
30
+ fluent_port: 24224
31
+ tag: 'foo'
32
+ messages_type: 'string'
32
33
 
33
34
  test:
34
- fluent_host: '127.0.0.1'
35
- fluent_port: 24224
36
- tag: 'foo'
35
+ fluent_host: '127.0.0.1'
36
+ fluent_port: 24224
37
+ tag: 'foo'
38
+ messages_type: 'string'
37
39
 
38
40
  production:
39
- fluent_host: '127.0.0.1'
40
- fluent_port: 24224
41
- tag: 'foo'
41
+ fluent_host: '127.0.0.1'
42
+ fluent_port: 24224
43
+ tag: 'foo'
44
+ messages_type: 'string'
45
+
46
+ * fluent_host: The host name of Fluentd.
47
+ * fluent_port: The port number of Fluentd.
48
+ * tag: The tag of the Fluentd event.
49
+ * messages_type: The type of log messags. 'string' or 'array'.
50
+ If it is 'string', the log messages is a String.
51
+ ```
52
+ 2013-01-18T15:04:50+09:00 foo {"messages":"Started GET \"/\" for 127.0.0.1 at 2013-01-18 15:04:49 +0900\nProcessing by TopController#index as HTML\nCompleted 200 OK in 635ms (Views: 479.3ms | ActiveRecord: 39.6ms)"],"level":"INFO"}
53
+ ```
54
+ If it is 'array', the log messages is an Array.
55
+ ```
56
+ 2013-01-18T15:04:50+09:00 foo {"messages":["Started GET \"/\" for 127.0.0.1 at 2013-01-18 15:04:49 +0900","Processing by TopController#index as HTML","Completed 200 OK in 635ms (Views: 479.3ms | ActiveRecord: 39.6ms)"],"level":"INFO"}
57
+ ```
58
+
59
+ If your Rails version is older than v3.2.9, You must set a dummy value to config.log_tags.
60
+
61
+ config.log_tags = ['nothing']
42
62
 
43
63
 
44
64
  ## Contributing
@@ -6,7 +6,7 @@ require 'act-fluent-logger-rails/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = "act-fluent-logger-rails"
8
8
  gem.version = ActFluentLoggerRails::VERSION
9
- gem.authors = ["Yoshinori Tahara"]
9
+ gem.authors = ["TAHARA Yoshinori"]
10
10
  gem.email = ["read.eval.print@gmail.com"]
11
11
  gem.description = %q{Fluent logger}
12
12
  gem.summary = %q{Fluent logger}
@@ -10,7 +10,8 @@ module ActFluentLoggerRails
10
10
  settings = {
11
11
  tag: fluent_config['tag'],
12
12
  host: fluent_config['fluent_host'],
13
- port: fluent_config['fluent_port']
13
+ port: fluent_config['fluent_port'],
14
+ messages_type: fluent_config['messages_type'],
14
15
  }
15
16
  @level = SEV_LABEL.index(Rails.application.config.log_level.to_s.upcase)
16
17
  super(::ActFluentLoggerRails::FluentLogger.new(settings, @level))
@@ -39,6 +40,7 @@ module ActFluentLoggerRails
39
40
  self.level = level
40
41
  port = options[:port]
41
42
  host = options[:host]
43
+ @messages_type = (options[:messages_type] || :array).to_sym
42
44
  @tag = options[:tag]
43
45
  @fluent_logger = ::Fluent::Logger::FluentLogger.new(nil, host: host, port: port)
44
46
  @severity = 0
@@ -52,7 +54,12 @@ module ActFluentLoggerRails
52
54
 
53
55
  def flush
54
56
  return if @messages.empty?
55
- @fluent_logger.post(@tag, messages: @messages, level: format_severity(@severity))
57
+ messages = if @messages_type == :string
58
+ @messages.join("\n")
59
+ else
60
+ @messages
61
+ end
62
+ @fluent_logger.post(@tag, messages: messages, level: format_severity(@severity))
56
63
  @severity = 0
57
64
  @messages.clear
58
65
  end
@@ -1,3 +1,3 @@
1
1
  module ActFluentLoggerRails
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: act-fluent-logger-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
- - Yoshinori Tahara
8
+ - TAHARA Yoshinori
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-22 00:00:00.000000000 Z
12
+ date: 2013-01-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -67,6 +67,7 @@ extensions: []
67
67
  extra_rdoc_files: []
68
68
  files:
69
69
  - .gitignore
70
+ - CHANGELOG.md
70
71
  - Gemfile
71
72
  - LICENSE.txt
72
73
  - README.md