log4r 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README +3 -4
- data/Rakefile +2 -2
- data/TODO +0 -2
- data/src/log4r.rb +2 -2
- data/src/log4r/GDC.rb +17 -16
- data/src/log4r/NDC.rb +4 -4
- data/src/log4r/outputter/fileoutputter.rb +2 -2
- metadata +2 -203
- data/examples/logs/TestSize000001.log +0 -576
- data/examples/logs/TestSize000002.log +0 -567
- data/examples/logs/TestSize000003.log +0 -552
- data/examples/logs/TestSize000004.log +0 -552
- data/examples/logs/TestSize000005.log +0 -552
- data/examples/logs/TestSize000006.log +0 -552
- data/examples/logs/TestSize000007.log +0 -552
- data/examples/logs/TestSize000008.log +0 -552
- data/examples/logs/TestSize000009.log +0 -552
- data/examples/logs/TestSize000010.log +0 -552
- data/examples/logs/TestSize000011.log +0 -552
- data/examples/logs/TestSize000012.log +0 -552
- data/examples/logs/TestSize000013.log +0 -552
- data/examples/logs/TestSize000014.log +0 -552
- data/examples/logs/TestSize000015.log +0 -552
- data/examples/logs/TestSize000016.log +0 -552
- data/examples/logs/TestSize000017.log +0 -552
- data/examples/logs/TestSize000018.log +0 -552
- data/examples/logs/TestSize000019.log +0 -535
- data/examples/logs/TestSize000020.log +0 -534
- data/examples/logs/TestSize000021.log +0 -534
- data/examples/logs/TestSize000022.log +0 -534
- data/examples/logs/TestSize000023.log +0 -534
- data/examples/logs/TestSize000024.log +0 -534
- data/examples/logs/TestSize000025.log +0 -534
- data/examples/logs/TestSize000026.log +0 -534
- data/examples/logs/TestSize000027.log +0 -534
- data/examples/logs/TestSize000028.log +0 -534
- data/examples/logs/TestSize000029.log +0 -534
- data/examples/logs/TestSize000030.log +0 -534
- data/examples/logs/TestSize000031.log +0 -534
- data/examples/logs/TestSize000032.log +0 -534
- data/examples/logs/TestSize000033.log +0 -534
- data/examples/logs/TestSize000034.log +0 -534
- data/examples/logs/TestSize000035.log +0 -534
- data/examples/logs/TestSize000036.log +0 -534
- data/examples/logs/TestSize000037.log +0 -534
- data/examples/logs/TestSize000038.log +0 -534
- data/examples/logs/TestSize000039.log +0 -534
- data/examples/logs/TestSize000040.log +0 -534
- data/examples/logs/TestSize000041.log +0 -534
- data/examples/logs/TestSize000042.log +0 -534
- data/examples/logs/TestSize000043.log +0 -534
- data/examples/logs/TestSize000044.log +0 -534
- data/examples/logs/TestSize000045.log +0 -534
- data/examples/logs/TestSize000046.log +0 -534
- data/examples/logs/TestSize000047.log +0 -534
- data/examples/logs/TestSize000048.log +0 -534
- data/examples/logs/TestSize000049.log +0 -534
- data/examples/logs/TestSize000050.log +0 -534
- data/examples/logs/TestSize000051.log +0 -534
- data/examples/logs/TestSize000052.log +0 -534
- data/examples/logs/TestSize000053.log +0 -534
- data/examples/logs/TestSize000054.log +0 -534
- data/examples/logs/TestSize000055.log +0 -534
- data/examples/logs/TestSize000056.log +0 -534
- data/examples/logs/TestSize000057.log +0 -534
- data/examples/logs/TestSize000058.log +0 -534
- data/examples/logs/TestSize000059.log +0 -534
- data/examples/logs/TestSize000060.log +0 -534
- data/examples/logs/TestSize000061.log +0 -534
- data/examples/logs/TestSize000062.log +0 -534
- data/examples/logs/TestSize000063.log +0 -534
- data/examples/logs/TestSize000064.log +0 -534
- data/examples/logs/TestSize000065.log +0 -534
- data/examples/logs/TestSize000066.log +0 -534
- data/examples/logs/TestSize000067.log +0 -534
- data/examples/logs/TestSize000068.log +0 -534
- data/examples/logs/TestSize000069.log +0 -534
- data/examples/logs/TestSize000070.log +0 -534
- data/examples/logs/TestSize000071.log +0 -534
- data/examples/logs/TestSize000072.log +0 -534
- data/examples/logs/TestSize000073.log +0 -534
- data/examples/logs/TestSize000074.log +0 -534
- data/examples/logs/TestSize000075.log +0 -534
- data/examples/logs/TestSize000076.log +0 -534
- data/examples/logs/TestSize000077.log +0 -534
- data/examples/logs/TestSize000078.log +0 -534
- data/examples/logs/TestSize000079.log +0 -534
- data/examples/logs/TestSize000080.log +0 -534
- data/examples/logs/TestSize000081.log +0 -534
- data/examples/logs/TestSize000082.log +0 -534
- data/examples/logs/TestSize000083.log +0 -534
- data/examples/logs/TestSize000084.log +0 -534
- data/examples/logs/TestSize000085.log +0 -534
- data/examples/logs/TestSize000086.log +0 -534
- data/examples/logs/TestSize000087.log +0 -534
- data/examples/logs/TestSize000088.log +0 -534
- data/examples/logs/TestSize000089.log +0 -534
- data/examples/logs/TestSize000090.log +0 -534
- data/examples/logs/TestSize000091.log +0 -534
- data/examples/logs/TestSize000092.log +0 -534
- data/examples/logs/TestSize000093.log +0 -534
- data/examples/logs/TestSize000094.log +0 -534
- data/examples/logs/TestSize000095.log +0 -534
- data/examples/logs/TestSize000096.log +0 -534
- data/examples/logs/TestSize000097.log +0 -534
- data/examples/logs/TestSize000098.log +0 -534
- data/examples/logs/TestSize000099.log +0 -534
- data/examples/logs/TestSize000100.log +0 -534
- data/examples/logs/TestSize000101.log +0 -534
- data/examples/logs/TestSize000102.log +0 -534
- data/examples/logs/TestSize000103.log +0 -534
- data/examples/logs/TestSize000104.log +0 -534
- data/examples/logs/TestSize000105.log +0 -534
- data/examples/logs/TestSize000106.log +0 -534
- data/examples/logs/TestSize000107.log +0 -534
- data/examples/logs/TestSize000108.log +0 -534
- data/examples/logs/TestSize000109.log +0 -534
- data/examples/logs/TestSize000110.log +0 -534
- data/examples/logs/TestSize000111.log +0 -534
- data/examples/logs/TestSize000112.log +0 -534
- data/examples/logs/TestSize000113.log +0 -534
- data/examples/logs/TestSize000114.log +0 -534
- data/examples/logs/TestSize000115.log +0 -534
- data/examples/logs/TestSize000116.log +0 -534
- data/examples/logs/TestSize000117.log +0 -534
- data/examples/logs/TestSize000118.log +0 -534
- data/examples/logs/TestSize000119.log +0 -534
- data/examples/logs/TestSize000120.log +0 -534
- data/examples/logs/TestSize000121.log +0 -534
- data/examples/logs/TestSize000122.log +0 -534
- data/examples/logs/TestSize000123.log +0 -534
- data/examples/logs/TestSize000124.log +0 -534
- data/examples/logs/TestSize000125.log +0 -534
- data/examples/logs/TestSize000126.log +0 -534
- data/examples/logs/TestSize000127.log +0 -534
- data/examples/logs/TestSize000128.log +0 -534
- data/examples/logs/TestSize000129.log +0 -534
- data/examples/logs/TestSize000130.log +0 -534
- data/examples/logs/TestSize000131.log +0 -534
- data/examples/logs/TestSize000132.log +0 -534
- data/examples/logs/TestSize000133.log +0 -534
- data/examples/logs/TestSize000134.log +0 -534
- data/examples/logs/TestSize000135.log +0 -534
- data/examples/logs/TestSize000136.log +0 -534
- data/examples/logs/TestSize000137.log +0 -534
- data/examples/logs/TestSize000138.log +0 -534
- data/examples/logs/TestSize000139.log +0 -534
- data/examples/logs/TestSize000140.log +0 -534
- data/examples/logs/TestSize000141.log +0 -534
- data/examples/logs/TestSize000142.log +0 -534
- data/examples/logs/TestSize000143.log +0 -534
- data/examples/logs/TestSize000144.log +0 -534
- data/examples/logs/TestSize000145.log +0 -534
- data/examples/logs/TestSize000146.log +0 -534
- data/examples/logs/TestSize000147.log +0 -534
- data/examples/logs/TestSize000148.log +0 -534
- data/examples/logs/TestSize000149.log +0 -534
- data/examples/logs/TestSize000150.log +0 -534
- data/examples/logs/TestSize000151.log +0 -534
- data/examples/logs/TestSize000152.log +0 -534
- data/examples/logs/TestSize000153.log +0 -534
- data/examples/logs/TestSize000154.log +0 -534
- data/examples/logs/TestSize000155.log +0 -534
- data/examples/logs/TestSize000156.log +0 -534
- data/examples/logs/TestSize000157.log +0 -534
- data/examples/logs/TestSize000158.log +0 -534
- data/examples/logs/TestSize000159.log +0 -534
- data/examples/logs/TestSize000160.log +0 -534
- data/examples/logs/TestSize000161.log +0 -534
- data/examples/logs/TestSize000162.log +0 -534
- data/examples/logs/TestSize000163.log +0 -534
- data/examples/logs/TestSize000164.log +0 -534
- data/examples/logs/TestSize000165.log +0 -534
- data/examples/logs/TestSize000166.log +0 -534
- data/examples/logs/TestSize000167.log +0 -534
- data/examples/logs/TestSize000168.log +0 -534
- data/examples/logs/TestSize000169.log +0 -534
- data/examples/logs/TestSize000170.log +0 -534
- data/examples/logs/TestSize000171.log +0 -534
- data/examples/logs/TestSize000172.log +0 -534
- data/examples/logs/TestSize000173.log +0 -534
- data/examples/logs/TestSize000174.log +0 -534
- data/examples/logs/TestSize000175.log +0 -534
- data/examples/logs/TestSize000176.log +0 -534
- data/examples/logs/TestSize000177.log +0 -534
- data/examples/logs/TestSize000178.log +0 -534
- data/examples/logs/TestSize000179.log +0 -534
- data/examples/logs/TestSize000180.log +0 -534
- data/examples/logs/TestSize000181.log +0 -534
- data/examples/logs/TestSize000182.log +0 -534
- data/examples/logs/TestSize000183.log +0 -534
- data/examples/logs/TestSize000184.log +0 -534
- data/examples/logs/TestSize000185.log +0 -534
- data/examples/logs/TestSize000186.log +0 -534
- data/examples/logs/TestSize000187.log +0 -312
- data/examples/logs/TestTime000001.log +0 -11
- data/examples/logs/TestTime000002.log +0 -10
- data/examples/logs/TestTime000003.log +0 -10
- data/examples/logs/TestTime000004.log +0 -10
- data/examples/logs/TestTime000005.log +0 -10
- data/examples/logs/TestTime000006.log +0 -10
- data/examples/logs/TestTime000007.log +0 -10
- data/examples/logs/TestTime000008.log +0 -10
- data/examples/logs/TestTime000009.log +0 -10
- data/examples/logs/TestTime000010.log +0 -9
- data/src/log4r/outputter/bob.patch +0 -25
- data/src/log4r/outputter/emailoutputter.rb.orig +0 -118
- data/src/log4r/outputter/emailoutputter.rb.rej +0 -46
- data/src/log4r/outputter/win32eventoutputter.rb +0 -136
@@ -1,118 +0,0 @@
|
|
1
|
-
# :include: ../rdoc/emailoutputter
|
2
|
-
|
3
|
-
require 'log4r/outputter/outputter'
|
4
|
-
require 'log4r/staticlogger'
|
5
|
-
require 'net/smtp'
|
6
|
-
|
7
|
-
module Log4r
|
8
|
-
|
9
|
-
class EmailOutputter < Outputter
|
10
|
-
attr_reader :server, :port, :domain, :acct, :authtype, :subject
|
11
|
-
|
12
|
-
def initialize(_name, hash={})
|
13
|
-
super(_name, hash)
|
14
|
-
validate(hash)
|
15
|
-
@buff = []
|
16
|
-
begin
|
17
|
-
Logger.log_internal {
|
18
|
-
"EmailOutputter '#{@name}' running SMTP client on #{@server}:#{@port}"
|
19
|
-
}
|
20
|
-
rescue Exception => e
|
21
|
-
Logger.log_internal(-2) {
|
22
|
-
"EmailOutputter '#{@name}' failed to start SMTP client!"
|
23
|
-
}
|
24
|
-
Logger.log_internal {e}
|
25
|
-
self.level = OFF
|
26
|
-
raise e
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# send out an email with the current buffer
|
31
|
-
def flush
|
32
|
-
synch { send_mail }
|
33
|
-
Logger.log_internal {"Flushed EmailOutputter '#{@name}'"}
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
def validate(hash)
|
39
|
-
@buffsize = (hash[:buffsize] or hash['buffsize'] or 100).to_i
|
40
|
-
@formatfirst = Log4rTools.decode_bool(hash, :formatfirst, false)
|
41
|
-
decode_immediate_at(hash)
|
42
|
-
validate_smtp_params(hash)
|
43
|
-
end
|
44
|
-
|
45
|
-
def decode_immediate_at(hash)
|
46
|
-
@immediate = Hash.new
|
47
|
-
_at = (hash[:immediate_at] or hash['immediate_at'])
|
48
|
-
return if _at.nil?
|
49
|
-
Log4rTools.comma_split(_at).each {|lname|
|
50
|
-
level = LNAMES.index(lname)
|
51
|
-
if level.nil?
|
52
|
-
Logger.log_internal(-2) do
|
53
|
-
"EmailOutputter: skipping bad immediate_at level name '#{lname}'"
|
54
|
-
end
|
55
|
-
next
|
56
|
-
end
|
57
|
-
@immediate[level] = true
|
58
|
-
}
|
59
|
-
end
|
60
|
-
|
61
|
-
def validate_smtp_params(hash)
|
62
|
-
@from = (hash[:from] or hash['from'])
|
63
|
-
raise ArgumentError, "Must specify from address" if @from.nil?
|
64
|
-
_to = (hash[:to] or hash['to'] or "")
|
65
|
-
@to = Log4rTools.comma_split(_to)
|
66
|
-
raise ArgumentError, "Must specify recepients" if @to.empty?
|
67
|
-
@server = (hash[:server] or hash['server'] or 'localhost')
|
68
|
-
@port = (hash[:port] or hash['port'] or 25).to_i
|
69
|
-
@domain = (hash[:domain] or hash['domain'] or ENV['HOSTNAME'])
|
70
|
-
@acct = (hash[:acct] or hash['acct'])
|
71
|
-
@passwd = (hash[:passwd] or hash['passwd'])
|
72
|
-
@authtype = (hash[:authtype] or hash['authtype'] or :cram_md5).to_s.intern
|
73
|
-
@subject = (hash[:subject] or hash['subject'] or "Message of #{$0}")
|
74
|
-
@params = [@server, @port, @domain, @acct, @passwd, @authtype]
|
75
|
-
end
|
76
|
-
|
77
|
-
def canonical_log(event)
|
78
|
-
synch {
|
79
|
-
@buff.push case @formatfirst
|
80
|
-
when true then @formatter.format event
|
81
|
-
else event
|
82
|
-
end
|
83
|
-
send_mail if @buff.size >= @buffsize or @immediate[event.level]
|
84
|
-
}
|
85
|
-
end
|
86
|
-
|
87
|
-
def send_mail
|
88
|
-
msg =
|
89
|
-
case @formatfirst
|
90
|
-
when true then @buff.join
|
91
|
-
else @buff.collect{|e| @formatter.format e}.join
|
92
|
-
end
|
93
|
-
|
94
|
-
### build a mail header for RFC 822
|
95
|
-
rfc822msg =
|
96
|
-
"From: #{@from}\n" +
|
97
|
-
"To: #{@to}\n" +
|
98
|
-
"Subject: #{@subject}\n" +
|
99
|
-
"Date: #{Time.now.strftime( "%a, %d %b %Y %H:%M:%S %z %Z")}\n" +
|
100
|
-
"Message-Id: <#{"%.8f" % Time.now.to_f}@#{@domain}>\n\n" +
|
101
|
-
"#{msg}"
|
102
|
-
|
103
|
-
### send email
|
104
|
-
begin Net::SMTP.start(*@params) do |smtp|
|
105
|
-
smtp.sendmail(rfc822msg, @from, @to)
|
106
|
-
end
|
107
|
-
rescue Exception => e
|
108
|
-
Logger.log_internal(-2) {
|
109
|
-
"EmailOutputter '#{@name}' couldn't send email!"
|
110
|
-
}
|
111
|
-
Logger.log_internal {e}
|
112
|
-
self.level = OFF
|
113
|
-
raise e
|
114
|
-
ensure @buff.clear
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
***************
|
2
|
-
*** 100,114 ****
|
3
|
-
"Message-Id: <#{"%.8f" % Time.now.to_f}@#{@domain}>\n\n" +
|
4
|
-
"#{msg}"
|
5
|
-
|
6
|
-
- ### send email
|
7
|
-
- begin @smtp.sendmail(rfc822msg, @from, @to)
|
8
|
-
- rescue Exception => e
|
9
|
-
- Logger.log_internal(-2) {
|
10
|
-
- "EmailOutputter '#{@name}' couldn't send email!"
|
11
|
-
- }
|
12
|
-
- Logger.log_internal {e}
|
13
|
-
- self.level = OFF
|
14
|
-
- ensure @buff.clear
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
--- 100,127 ----
|
19
|
-
"Message-Id: <#{"%.8f" % Time.now.to_f}@#{@domain}>\n\n" +
|
20
|
-
"#{msg}"
|
21
|
-
|
22
|
-
+ begin
|
23
|
-
+ 3.times do
|
24
|
-
+ begin
|
25
|
-
+ ### send email
|
26
|
-
+ @smtp.sendmail(rfc822msg, @from, @to)
|
27
|
-
+ break
|
28
|
-
+ rescue Net::SMTPServerBusy => e
|
29
|
-
+ Logger.log_internal(-2) {
|
30
|
-
+ "Try to restart EmailOutputter '#{@name}'! (#{e.message})"
|
31
|
-
+ }
|
32
|
-
+ @smtp = Net::SMTP.start(*@params)
|
33
|
-
+ rescue Exception => e
|
34
|
-
+ Logger.log_internal(-2) {
|
35
|
-
+ "EmailOutputter '#{@name}' couldn't send email! (#{e.message})"
|
36
|
-
+ break
|
37
|
-
+ }
|
38
|
-
+ Logger.log_internal {e}
|
39
|
-
+ self.level = OFF
|
40
|
-
+ end
|
41
|
-
+ end
|
42
|
-
+ ensure
|
43
|
-
+ @buff.clear
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,136 +0,0 @@
|
|
1
|
-
# :include: ../rdoc/win32eventoutputter
|
2
|
-
#
|
3
|
-
# Version:: $Id: syslogoutputter.rb,v 1.5 2009/09/25 20:33:33 colbygk Exp $
|
4
|
-
# Author:: Colby Gutierrez-Kraybill
|
5
|
-
#
|
6
|
-
# NOTE: THIS IS A DEVELOPMENT VERSION AND IS NOT READY FOR USE
|
7
|
-
# INFACT, IT MAY NEVER BE READY FOR USE, AS TRYING TO INTERACT
|
8
|
-
# WITH THE WIN32 EVENTLOG API REQUIRES USER INTERVENTION TO LOOKUP
|
9
|
-
# event_id AND category CODES THAT THIS LIBRARY CANNOT KNOW A PRIORI
|
10
|
-
#
|
11
|
-
# I have added this to the cvs tree to keep as a work in flight
|
12
|
-
# It is presently UNUSABLE
|
13
|
-
#
|
14
|
-
|
15
|
-
require 'log4r/formatter/formatter'
|
16
|
-
require 'log4r/outputter/outputter'
|
17
|
-
require 'log4r/configurator'
|
18
|
-
require 'win32/eventlog'
|
19
|
-
|
20
|
-
module Log4r
|
21
|
-
include Win32
|
22
|
-
|
23
|
-
class Win32EventLogOutputter < Outputter
|
24
|
-
|
25
|
-
# maps default log4r levels to win32 event priorities
|
26
|
-
# (logevents never see ALL and OFF)
|
27
|
-
# WIN32EVENTLOG Levels are:
|
28
|
-
# "SUCCESS" => EVENTLOG_SUCCESS
|
29
|
-
# "AUDIT_SUCCESS" => AUDIT_SUCCESS
|
30
|
-
# "INFO" => EVENTLOG_INFO
|
31
|
-
# "WARN" => EVENTLOG_WARN
|
32
|
-
# "ERROR" => EVENTLOG_ERROR
|
33
|
-
# "AUDIT_FAILURE" => AUDIT_FAILURE
|
34
|
-
WIN32EVENTLOG_LEVELS_MAP = {
|
35
|
-
"SUCCESS" => EVENTLOG_SUCCESS,
|
36
|
-
"AUDIT_SUCCESS" => AUDIT_SUCCESS,
|
37
|
-
"INFO" => EVENTLOG_INFO,
|
38
|
-
"WARN" => EVENTLOG_WARN,
|
39
|
-
"ERROR" => EVENTLOG_ERROR,
|
40
|
-
"AUDIT_FAILURE" => AUDIT_FAILURE
|
41
|
-
}
|
42
|
-
|
43
|
-
# mapping from Log4r default levels to win32 eventlog, by string name
|
44
|
-
# "DEBUG" => "INFO" # by default DEBUG is not in win32 eventlog
|
45
|
-
# "INFO" => "INFO"
|
46
|
-
# "WARN" => "WARN"
|
47
|
-
# "ERROR" => "ERROR"
|
48
|
-
# "FATAL" => "ERROR" # by default FATAL is not in win32 eventlog
|
49
|
-
# "SUCCESS" => "SUCCESS" # by default SUCCESS is not in log4r
|
50
|
-
# "AUDIT_SUCCESS" => "AUDIT_SUCCESS" # by default AUDIT_SUCCESS is not in log4r
|
51
|
-
# "AUDIT_FAILURE" => "AUDIT_FAILURE" # by default AUDIT_FATAL is not in log4r
|
52
|
-
WIN32EVENTLOG_LOG4R_MAP = {
|
53
|
-
"DEBUG" => "INFO",
|
54
|
-
"INFO" => "INFO",
|
55
|
-
"WARN" => "WARN",
|
56
|
-
"ERROR" => "ERROR",
|
57
|
-
"FATAL" => "ERROR",
|
58
|
-
"SUCCESS" => "SUCCESS",
|
59
|
-
"AUDIT_SUCCESS" => "AUDIT_SUCCESS",
|
60
|
-
"AUDIT_FAILURE" => "AUDIT_FAILURE"
|
61
|
-
}
|
62
|
-
|
63
|
-
@levels_map = WIN32EVENTLOG_LOG4R_MAP
|
64
|
-
|
65
|
-
# There are 3 hash arguments
|
66
|
-
#
|
67
|
-
# [<tt>:registry_source</tt>] eventlog registry source, defaults to "Application"
|
68
|
-
# [<tt>:source</tt>] eventlog source, defaults to _name
|
69
|
-
def initialize(_name, hash={})
|
70
|
-
super(_name, hash)
|
71
|
-
registry_source = (hash[:registry_source] or hash['registry_source'] or "Application")
|
72
|
-
@source = (hash[:source] or hash['source'] or _name)
|
73
|
-
logopt = (hash[:logopt] or hash['logopt'] or LOG_PID | LOG_CONS).to_i
|
74
|
-
facility = (hash[:facility] or hash['facility'] or LOG_USER).to_i
|
75
|
-
map_levels_by_name_to_eventlog()
|
76
|
-
if ( Syslog.opened? ) then
|
77
|
-
Logger.log_internal { "Syslog already initialized, to alter, " +
|
78
|
-
"you must close first"}
|
79
|
-
end
|
80
|
-
# @syslog = ( Syslog.opened? ) ? Syslog : Syslog.open(ident, logopt, facility)
|
81
|
-
end
|
82
|
-
|
83
|
-
def closed?
|
84
|
-
return true # !@syslog.opened?
|
85
|
-
end
|
86
|
-
|
87
|
-
def close
|
88
|
-
#@syslog.close unless @syslog.nil?
|
89
|
-
#@level = OFF
|
90
|
-
OutputterFactory.create_methods(self)
|
91
|
-
Logger.log_internal {"Outputter '#{@name}' closed Syslog and set to OFF"}
|
92
|
-
end
|
93
|
-
|
94
|
-
# A single hash argument that maps custom names to eventlog names
|
95
|
-
#
|
96
|
-
# [<tt>levels_map</tt>] A map that will create a linkage between levels
|
97
|
-
# in a hash and underlying eventlog levels.
|
98
|
-
# By default, these are direct mapping of the log4r
|
99
|
-
# levels (e.g. "DEBUG" => "DEBUG")
|
100
|
-
# If you have defined your own custom levels, you
|
101
|
-
# should provide this underlying mapping, otherwise
|
102
|
-
# all messages will be mapped to the underlying eventlog
|
103
|
-
# level of INFO by default.
|
104
|
-
# e.g.
|
105
|
-
# You have created custom levels called:
|
106
|
-
# <tt>Configurator.custom_levels "HIGH", "MEDIUM", "LOW"</tt>
|
107
|
-
# To map these to 'equivilent' eventlog levels, after instantiatin
|
108
|
-
# a eventlogoutputter:
|
109
|
-
# <tt>EventLogOutputter.map_levels_by_name_to_eventlog(
|
110
|
-
# { "HIGH" => "ALERT", "MEDIUM" => "WARN", "LOW" => "INFO" }
|
111
|
-
# )</tt>
|
112
|
-
def map_levels_by_name_to_eventlog( lmap = WIN32EVENTLOG_LOG4R_MAP )
|
113
|
-
@levels_map = lmap
|
114
|
-
end
|
115
|
-
|
116
|
-
def get_levels_map()
|
117
|
-
return @levels_map
|
118
|
-
end
|
119
|
-
|
120
|
-
private
|
121
|
-
|
122
|
-
def canonical_log(logevent)
|
123
|
-
pri = SYSLOG_LEVELS_MAP[@levels_map[LNAMES[logevent.level]]] rescue pri = LOG_INFO
|
124
|
-
o = format(logevent)
|
125
|
-
if o.kind_of? Exception then
|
126
|
-
msg = "#{o.class} at (#{o.backtrace[0]}): #{o.message}"
|
127
|
-
elsif o.respond_to? :to_str then
|
128
|
-
msg = o.to_str
|
129
|
-
else
|
130
|
-
msg = o.inspect
|
131
|
-
end
|
132
|
-
|
133
|
-
# @syslog.log(pri, '%s', msg)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|