-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathparser.rb
49 lines (40 loc) · 901 Bytes
/
parser.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module RubySyslog
require 'thread'
class Parser
# Allows accessing and altering the configuration of the Syslog parser
attr_accessor :config
def initialize(config = {:verbose => false})
require 'lib/syslogproto'
puts "SyslogProto parser loaded [ OK ]" if config[:verbose]
@config = config
end
# Parses packets and returns / yields the syslog object, depending on
# if a block was passed
def parse(packet)
if block_given?
yield SyslogProto.parse(packet)
else
return SyslogProto.parse(packet)
end
end
# Class method for accessing the parse() method without creating an instance
# of the Parser class
def self.quick_parse(packet)
return parse(packet)
end
end
class LogQueue < Queue
attr_accessor :lock
def initialize
@lock = false
end
def locked?
return @lock
end
def flush!
clear
end
end
class LogMutex < Mutex
end
end