-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogmailer_lib.rb
executable file
·60 lines (48 loc) · 1.69 KB
/
logmailer_lib.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
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/ruby
def ls_directory(path)
begin
filenames = Dir.open(path).entries
ret = Array.new
filenames.each do |filename|
ret.push(path + filename)
end
return ret
rescue
return Array.new
end
end
def config_check?(log_config)
abort("An entry is missing a name") if log_config[:name].nil?
if log_config[:files].class != Array
abort("#{log_config[:name]} entry has malformed files list")
end
if log_config[:delimiters].class != Array
abort("#{log_config[:name]} entry has malformed delimiters list")
end
if log_config[:entry_search].class != Array
abort("#{log_config[:name]} entry has malformed entry_search list")
end
if log_config[:reject_global].class != Array
abort("#{log_config[:name]} entry has malformed reject_global list")
end
if log_config[:reject_high].class != Array
abort("#{log_config[:name]} entry has malformed reject_high list")
end
if log_config[:entry_tag].class != Array
abort("#{log_config[:name]} entry has malformed entry_tag list")
end
log_config[:entry_tag].each do |entry_tag|
if entry_tag.class != Array
abort("#{log_config[:name]} entry has malformed entry_tag list")
end
end
if log_config[:token_scan].class != Array
abort("#{log_config[:name]} entry has malformed token_scan list")
elsif log_config[:token_scan].length < 1
abort("#{log_config[:name]} entry cannot have a blank token_scan list")
end
if log_config[:low_thresh].class != Fixnum
abort("#{log_config[:name]} entry has malformed low_thresh number")
end
return true
end