corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | #region Copyright & License |
2 | // |
||
3 | // Copyright 2001-2004 The Apache Software Foundation |
||
4 | // |
||
5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
||
6 | // you may not use this file except in compliance with the License. |
||
7 | // You may obtain a copy of the License at |
||
8 | // |
||
9 | // http://www.apache.org/licenses/LICENSE-2.0 |
||
10 | // |
||
11 | // Unless required by applicable law or agreed to in writing, software |
||
12 | // distributed under the License is distributed on an "AS IS" BASIS, |
||
13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
14 | // See the License for the specific language governing permissions and |
||
15 | // limitations under the License. |
||
16 | // |
||
17 | #endregion |
||
18 | |||
19 | using System; |
||
20 | using log4net.Core; |
||
21 | |||
22 | namespace WinGridProxy |
||
23 | { |
||
24 | public delegate void MessageLoggedEventHandler(object sender, MessageLoggedEventArgs e); |
||
25 | |||
26 | public class MessageLoggedEventArgs : EventArgs |
||
27 | { |
||
28 | private LoggingEvent m_loggingEvent; |
||
29 | |||
30 | public MessageLoggedEventArgs(LoggingEvent loggingEvent) |
||
31 | { |
||
32 | m_loggingEvent = loggingEvent; |
||
33 | } |
||
34 | public LoggingEvent LoggingEvent |
||
35 | { |
||
36 | get { return m_loggingEvent; } |
||
37 | } |
||
38 | } |
||
39 | |||
40 | public class FireEventAppender : log4net.Appender.AppenderSkeleton |
||
41 | { |
||
42 | private static FireEventAppender m_instance; |
||
43 | |||
44 | private FixFlags m_fixFlags = FixFlags.All; |
||
45 | |||
46 | // Event handler |
||
47 | public event MessageLoggedEventHandler MessageLoggedEvent; |
||
48 | |||
49 | // Easy singleton, gets the last instance created |
||
50 | public static FireEventAppender Instance |
||
51 | { |
||
52 | get { return m_instance; } |
||
53 | } |
||
54 | |||
55 | public FireEventAppender() |
||
56 | { |
||
57 | // Store the instance created |
||
58 | m_instance = this; |
||
59 | } |
||
60 | |||
61 | virtual public FixFlags Fix |
||
62 | { |
||
63 | get { return m_fixFlags; } |
||
64 | set { m_fixFlags = value; } |
||
65 | } |
||
66 | |||
67 | override protected void Append(LoggingEvent loggingEvent) |
||
68 | { |
||
69 | // Because we the LoggingEvent may be used beyond the lifetime |
||
70 | // of the Append() method we must fix any volatile data in the event |
||
71 | loggingEvent.Fix = this.Fix; |
||
72 | |||
73 | // Raise the event |
||
74 | MessageLoggedEventHandler handler = MessageLoggedEvent; |
||
75 | if (handler != null) |
||
76 | { |
||
77 | handler(this, new MessageLoggedEventArgs(loggingEvent)); |
||
78 | } |
||
79 | } |
||
80 | |||
81 | } |
||
82 | } |