logstash-lite 0.2.20101124004656 → 0.2.20101124030048

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  require "eventmachine"
2
2
  require "eventmachine-tail"
3
- require "logstash/namespace"
4
- require "logstash/inputs"
5
- require "logstash/outputs"
6
3
  require "logstash/filters"
4
+ require "logstash/inputs"
7
5
  require "logstash/logging"
6
+ require "logstash/namespace"
7
+ require "logstash/outputs"
8
8
 
9
9
  # Collect logs, ship them out.
10
10
  class LogStash::Agent
@@ -80,6 +80,9 @@ class LogStash::Agent
80
80
  @outputs << output
81
81
  end # each output
82
82
  end
83
+
84
+ # Register any signal handlers
85
+ sighandler
83
86
  end # def register
84
87
 
85
88
  public
@@ -124,4 +127,33 @@ class LogStash::Agent
124
127
  output(event)
125
128
  end
126
129
  end # def input
130
+
131
+ public
132
+ def sighandler
133
+ @sigchannel = EventMachine::Channel.new
134
+ Signal.trap("USR1") do
135
+ @sigchannel.push(:USR1)
136
+ end
137
+
138
+ @sigchannel.subscribe do |msg|
139
+ case msg
140
+ when :USR1
141
+ counts = Hash.new { |h,k| h[k] = 0 }
142
+ ObjectSpace.each_object do |obj|
143
+ counts[obj.class] += 1
144
+ end
145
+
146
+ @logger.info("SIGUSR1 received. Dumping state")
147
+ @logger.info("#{self.class.name} config")
148
+ @logger.info([" Inputs:", @inputs])
149
+ @logger.info([" Filters:", @filters])
150
+ @logger.info([" Outputs:", @outputs])
151
+
152
+ @logger.info("Dumping counts of objects by class")
153
+ counts.sort { |a,b| a[1] <=> b[1] or a[0] <=> b[0] }.each do |key, value|
154
+ @logger.info("Class: [#{value}] #{key}")
155
+ end
156
+ end
157
+ end
158
+ end
127
159
  end # class LogStash::Components::Agent
@@ -4,7 +4,7 @@ require "uri"
4
4
 
5
5
  # General event type. Will expand this in the future.
6
6
  module LogStash; class Event
7
- def initialize(data)
7
+ def initialize(data=Hash.new)
8
8
  @cancelled = false
9
9
  @data = {
10
10
  "@source" => "unknown",
@@ -14,4 +14,12 @@ class LogStash::Filters::Base
14
14
  def filter(event)
15
15
  raise "#{self.class}#filter must be overidden"
16
16
  end # def filter
17
+
18
+ def add_config(type, typeconfig)
19
+ if @config.include?(type)
20
+ @config[type].merge!(typeconfig)
21
+ else
22
+ @config[type] = typeconfig
23
+ end
24
+ end
17
25
  end # class LogStash::Filters::Base
@@ -93,7 +93,7 @@ class LogStash::Filters::Multiline < LogStash::Filters::Base
93
93
  key = [event.source, event.type]
94
94
  pending = @pending[key]
95
95
 
96
- @logger.info(["Reg: ", typeconfig["pattern"], event.message, match])
96
+ @logger.debug(["Reg: ", typeconfig["pattern"], event.message, match])
97
97
  case typeconfig["what"]
98
98
  when "previous"
99
99
  if match
data/lib/logstash/time.rb CHANGED
@@ -20,7 +20,9 @@ class LogStash::Time < ::Time
20
20
  def self.to_iso8601(obj)
21
21
  if obj.is_a?(DateTime)
22
22
  tz = obj.offset == 0 ? "Z" : obj.strftime("%z")
23
- return "%s.%06d%s" % [obj.strftime(ISO8601), obj.sec_fraction.to_f, tz]
23
+ # DateTime#sec_fraction is fractional seconds "of a day"
24
+ sec_fraction = (obj.sec_fraction.to_f * 86400 * 1000000)
25
+ return "%s.%06d%s" % [obj.strftime(ISO8601), sec_fraction, tz]
24
26
  else
25
27
  raise "Can't convert object of type #{obj.class} (#{obj}) to iso8601."
26
28
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-lite
3
3
  version: !ruby/object:Gem::Version
4
- hash: 40202248009335
4
+ hash: 40202248060119
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 20101124004656
10
- version: 0.2.20101124004656
9
+ - 20101124030048
10
+ version: 0.2.20101124030048
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordan Sissel