fluent-plugin-airbrake-logger 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1490f1bf0c515799878049536f1cfda972f8cc2b
4
- data.tar.gz: 86d57218a3e4e6575a916c5fcf4b50518d1c677f
3
+ metadata.gz: ee581109b0421a8c7c8dddab9339e06cdcad63c1
4
+ data.tar.gz: ad07df2ebc76fd13c9a31fa3093172cd80955c07
5
5
  SHA512:
6
- metadata.gz: 2976f851bc615ad454e429a59cd0d352de60097834016919a3c1dcbb9bf756b3b8677d1e36f6f041ae25faf6efb5c1c90a63c1a8252216f47a0340ea16e06a1d
7
- data.tar.gz: fdbca7e359179aec280affdf26ccae383af8750b95cdb1a36d4cf3079be39ab3330d1134c7a3186e2d2741cfca1d58db5fd1d8b40766bb59d005d119f15902ea
6
+ metadata.gz: 5a6a57f04e6803245107251d9606a4da8329f6fb0c5700411d5182b227a4851dd6440a699ec508318035523f63285c3c8abeaf48f4be6cc3438a1d7699f1e967
7
+ data.tar.gz: f0f1f4c0b3200c7e4a491b1a6392c0ee45611d9625cb1ddd48641dcd94aab5a03f74d5834b676c86e11b1a24f2336c41bc58badb8f28da2b741096d18cdc9d5e
@@ -4,12 +4,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-airbrake-logger"
7
- spec.version = "0.0.2"
7
+ spec.version = "0.0.3"
8
8
  spec.authors = ["Shuichi Ohsawa"]
9
9
  spec.email = ["ohsawa0515@gmail.com"]
10
10
 
11
- spec.summary = %q{Output filter plugin to Airbrake(Errbit) by fluent-logger}
12
- spec.description = %q{Output filter plugin to Airbrake(Errbit) by fluent-logger}
11
+ spec.summary = %q{Fluent output plugin to Airbrake(Errbit) by fluent-logger}
12
+ spec.description = %q{Fluent output plugin to Airbrake(Errbit) by fluent-logger}
13
13
  spec.homepage = "https://github.com/ohsawa0515/fluent-plugin-airbrake-logger"
14
14
  spec.license = "MIT"
15
15
 
@@ -1,7 +1,7 @@
1
- class Fluent::ErrbitGeesOutput < Fluent::Output
1
+ class Fluent::AirbrakeLoggerOutput < Fluent::Output
2
2
  Fluent::Plugin.register_output('airbrake_logger', self)
3
3
 
4
- LOGLEVEL_MAP = {
4
+ LOG_LEVEL_MAP = {
5
5
  'CRITICAL' => 50,
6
6
  'FATAL' => 50,
7
7
  'ERROR' => 40,
@@ -11,6 +11,8 @@ class Fluent::ErrbitGeesOutput < Fluent::Output
11
11
  'DEBUG' => 10
12
12
  }
13
13
 
14
+ CUT_OFF_CHAR = 60
15
+
14
16
  config_param :api_key, :string, :default => nil
15
17
  config_param :host, :string, :default => 'localhost'
16
18
  config_param :port, :integer, :default => '80'
@@ -39,9 +41,17 @@ class Fluent::ErrbitGeesOutput < Fluent::Output
39
41
  config_param :user_attributes, :string, :default => nil
40
42
  config_param :framework, :string, :default => nil
41
43
  config_param :project_id, :string, :default => nil
42
- config_param :loglevel, :string, :default => 'DEBUG'
44
+ config_param :log_level, :string, :default => 'DEBUG'
43
45
  config_param :log_path, :string, :default => nil
44
46
 
47
+ # record parameters
48
+ config_param :log_level_record, :string, :default => 'severity'
49
+ config_param :error_class_record, :string, :default => 'error_class'
50
+ config_param :batcktrace_record, :string, :default => 'error_backtrace'
51
+ config_param :error_message_record, :string, :default => 'error_message'
52
+ config_param :component_record, :string, :default => 'component'
53
+ config_param :action_record, :string, :default => 'action'
54
+
45
55
  def initialize
46
56
  super
47
57
  require 'airbrake'
@@ -78,22 +88,28 @@ class Fluent::ErrbitGeesOutput < Fluent::Output
78
88
  end
79
89
 
80
90
  @sender = Airbrake::Sender.new(@aconf)
81
- @loglevel = LOGLEVEL_MAP[@loglevel.upcase]
91
+ @log_level = LOG_LEVEL_MAP[@log_level.upcase]
82
92
  end
83
93
 
84
94
  def notification_needed(_tag, _time, record)
85
- severity_map = LOGLEVEL_MAP[record['severity']]
95
+ severity_map = LOG_LEVEL_MAP[record[@log_level_record].upcase]
86
96
 
87
- record['severity'] ? severity_map >= @loglevel : false
97
+ record[@log_level_record] ? severity_map >= @log_level : false
88
98
  end
89
99
 
90
100
  def build_error_message(record)
91
- error_message = record['error_message'] ? record['error_message'] : 'Notification'
92
- "[#{record['severity']}] #{error_message}"
101
+ error_message = record[@error_message_record] ? cut_down_message(record[@error_message_record]) :
102
+ (record['message'] ? cut_down_message(record['message']) : 'Notification')
103
+ "[#{record[@log_level_record]}] #{record[@error_class_record]} #{error_message}"
104
+ end
105
+
106
+ def cut_down_message(message)
107
+ message_to_s = message.is_a?(Array) ? message.join : message
108
+ message_to_s[0, CUT_OFF_CHAR]
93
109
  end
94
110
 
95
111
  def build_error_backtrace(record)
96
- return record['error_backtrace'] ? record['error_backtrace'] : (record['backtrace'] ? record['backtrace'] : "")
112
+ record[@batcktrace_record] ? record[@batcktrace_record] : (record['backtrace'] ? record['backtrace'] : "")
97
113
  end
98
114
 
99
115
  def emit(tag, es, chain)
@@ -101,16 +117,18 @@ class Fluent::ErrbitGeesOutput < Fluent::Output
101
117
 
102
118
  next unless notification_needed(tag, time, record)
103
119
 
104
- other_record = record.reject {|k, _| %w(error_class error_backtrace error_message application_name service_name).include?(k) }
120
+ other_record = record.reject {|k, _|
121
+ %W(#{@log_level_record} #{@error_class_record} #{@batcktrace_record}
122
+ #{@error_message_record} #{@component_record} #{@action_record} backtrace message).include?(k) }
105
123
 
106
124
  @notice = Airbrake::Notice.new(@aconf.merge(
107
125
  :api_key => @api_key,
108
- :error_class => record['error_class'],
126
+ :error_class => record[@error_class_record],
109
127
  :backtrace => build_error_backtrace(record),
110
128
  :error_message => build_error_message(record),
111
129
  :hostname => record['hostname'],
112
- :component => record['application_name'],
113
- :action => record['service_name'],
130
+ :component => record[@component_record],
131
+ :action => record[@action_record],
114
132
  :cgi_data => other_record
115
133
  ))
116
134
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-airbrake-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shuichi Ohsawa
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-30 00:00:00.000000000 Z
11
+ date: 2015-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -80,7 +80,7 @@ dependencies:
80
80
  - - '>='
81
81
  - !ruby/object:Gem::Version
82
82
  version: 4.3.0
83
- description: Output filter plugin to Airbrake(Errbit) by fluent-logger
83
+ description: Fluent output plugin to Airbrake(Errbit) by fluent-logger
84
84
  email:
85
85
  - ohsawa0515@gmail.com
86
86
  executables: []
@@ -118,5 +118,5 @@ rubyforge_project:
118
118
  rubygems_version: 2.0.14
119
119
  signing_key:
120
120
  specification_version: 4
121
- summary: Output filter plugin to Airbrake(Errbit) by fluent-logger
121
+ summary: Fluent output plugin to Airbrake(Errbit) by fluent-logger
122
122
  test_files: []