logstash_rails 0.0.11 → 0.0.12
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/Rakefile
CHANGED
data/lib/logstash_rails.rb
CHANGED
|
@@ -8,9 +8,24 @@ Dir[File.join(File.dirname(__FILE__), 'logstash_rails', '*.rb')].each do |file|
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
module LogstashRails
|
|
11
|
-
extend self
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
#
|
|
13
|
+
# configure LogstashRails
|
|
14
|
+
#
|
|
15
|
+
# @param options [Hash] configuration options
|
|
16
|
+
#
|
|
17
|
+
# @option options [Symbol] :transport The transport to use.
|
|
18
|
+
# @option options [Array<String, Regexp>] :events The list of events to subscribe
|
|
19
|
+
# @option options [Logger] :logger The logger for exceptions
|
|
20
|
+
#
|
|
21
|
+
# @return the configured transport
|
|
22
|
+
#
|
|
23
|
+
# @raise [KeyError] if no transport has been specified
|
|
24
|
+
#
|
|
25
|
+
# @see Transport available transports
|
|
26
|
+
# @see TransportBase#destroy
|
|
27
|
+
#
|
|
28
|
+
def self.config(options)
|
|
14
29
|
transport = options.fetch(:transport)
|
|
15
30
|
transport = transport.to_s.camelize.to_sym
|
|
16
31
|
|
|
@@ -8,11 +8,12 @@ module LogstashRails
|
|
|
8
8
|
logfile = options[:logfile] || 'log/logstash_rails.log'
|
|
9
9
|
|
|
10
10
|
@logger = ::Logger.new(logfile)
|
|
11
|
-
|
|
12
11
|
@logger.formatter = lambda do |severity, datetime, progname, msg|
|
|
13
12
|
"#{msg}\n"
|
|
14
13
|
end
|
|
15
14
|
@logger.level = Logger::INFO
|
|
15
|
+
|
|
16
|
+
super
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
def push(json_event)
|
|
@@ -2,6 +2,14 @@ module LogstashRails
|
|
|
2
2
|
module Transport
|
|
3
3
|
class Redis < TransportBase
|
|
4
4
|
|
|
5
|
+
# @param options [Hash] configuration options
|
|
6
|
+
#
|
|
7
|
+
# @option options [Symbol] :host ('127.0.0.1') the host with the redis
|
|
8
|
+
# server
|
|
9
|
+
# @option options [Symbol] :port (6379) the port to connect to
|
|
10
|
+
# @option options [Symbol] :redis_key ('logstash') the key of the redis
|
|
11
|
+
# list to which events will be pushed to
|
|
12
|
+
#
|
|
5
13
|
def initialize(options)
|
|
6
14
|
host = options[:host] || '127.0.0.1'
|
|
7
15
|
port = options[:port] || 6379
|
|
@@ -1,20 +1,15 @@
|
|
|
1
1
|
module LogstashRails
|
|
2
2
|
|
|
3
3
|
# base class for transports
|
|
4
|
-
#
|
|
5
4
|
class TransportBase
|
|
6
5
|
|
|
7
|
-
# @
|
|
8
|
-
#
|
|
9
|
-
# @option options [Array] :events The list of events to subscribe
|
|
10
|
-
# @option options [Logger] :logger The logger for exceptions
|
|
11
|
-
#
|
|
6
|
+
# @see LogstashRails.config
|
|
12
7
|
def initialize(options)
|
|
13
8
|
@events = options[:events] || [/.*/]
|
|
14
|
-
@
|
|
9
|
+
@error_logger = options[:logger]
|
|
15
10
|
|
|
16
11
|
if defined?(Rails)
|
|
17
|
-
@
|
|
12
|
+
@error_logger ||= Rails.logger
|
|
18
13
|
end
|
|
19
14
|
|
|
20
15
|
subscribe
|
|
@@ -51,8 +46,8 @@ module LogstashRails
|
|
|
51
46
|
end
|
|
52
47
|
|
|
53
48
|
def log(exception)
|
|
54
|
-
return unless @
|
|
55
|
-
@
|
|
49
|
+
return unless @error_logger
|
|
50
|
+
@error_logger.error(exception.message + "\n " + exception.backtrace.join("\n "))
|
|
56
51
|
end
|
|
57
52
|
|
|
58
53
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: logstash_rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.12
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -105,7 +105,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
105
105
|
version: '0'
|
|
106
106
|
segments:
|
|
107
107
|
- 0
|
|
108
|
-
hash: -
|
|
108
|
+
hash: -2947384106749656369
|
|
109
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
110
|
none: false
|
|
111
111
|
requirements:
|
|
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
114
114
|
version: '0'
|
|
115
115
|
segments:
|
|
116
116
|
- 0
|
|
117
|
-
hash: -
|
|
117
|
+
hash: -2947384106749656369
|
|
118
118
|
requirements: []
|
|
119
119
|
rubyforge_project:
|
|
120
120
|
rubygems_version: 1.8.24
|