-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathM_clsLogSaver__Template.def
123 lines (100 loc) · 3.28 KB
/
M_clsLogSaver__Template.def
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
'---------------------------------------------------------------------------------------
' Module : clsLogSaver__Template
' Author : K.Gundermann
' Date : 17.01.2012
' Purpose : Template Class for Creating new LogSaver Classes
' Notes : The following Items should be implemented
' colFilters : a Collection of Filter Objects (clsLogFilter)
' StartLog/StopLog :
' AddFilter : Adds a new Filter to colFilters
'---------------------------------------------------------------------------------------
Option Compare Database
Option Explicit
Implements ILogSaver
Private WithEvents c_Logger As clsLogger
Attribute c_Logger.VB_VarHelpID = -1
Private WithEvents c_Session As clsLogSession
Attribute c_Session.VB_VarHelpID = -1
Private c_Filters As clsLogFilterCollection
Private c_Name As String
Private Sub Class_Initialize()
Set c_Session = Logger.Log.Session
Set c_Filters = New clsLogFilterCollection
End Sub
Private Sub Class_Terminate()
Call StopLog
End Sub
' --- Public Interface ---
Public Sub StartLog()
Set c_Logger = Logger.Log
End Sub
Public Sub StopLog()
Set c_Logger = Nothing
End Sub
Public Sub SaveToLog(ByRef objLogEntry As clsLogEntry)
If Filters.MatchFilter(objLogEntry) Then
Call SaveToMyLog(objLogEntry)
End If
End Sub
Public Function AddFilter(ByVal TheFilter As clsLogFilter) As ILogSaver
Filters.AddFilter TheFilter
Set AddFilter = Me
End Function
Public Property Get ID() As Long
ID = ObjPtr(Me)
End Property
Public Property Get Name() As String
If c_Name = vbNullString Then
Name = TypeName(Me)
Else
Name = c_Name
End If
End Property
Public Property Let Name(ByVal TheName As String)
c_Name = TheName
End Property
' --- Private Functions ---
Private Property Get Filters() As clsLogFilterCollection
Set Filters = c_Filters
End Property
' --- Event Handler for Logger/Session Class ---
Private Sub c_Logger_SaveToLog(objLogEntry As clsLogEntry)
Call Me.SaveToLog(objLogEntry)
End Sub
Private Sub c_Session_Login()
' ToDo: We have now a logged In User
End Sub
Private Sub c_Session_Logout()
' ToDo: The user has logged out
End Sub
' --- Implements ILogSaver ---
Private Sub ILogSaver_StartLog()
Me.StartLog
End Sub
Private Sub ILogSaver_StopLog()
Me.StopLog
End Sub
Private Function ILogSaver_AddFilter(ByVal TheFilter As clsLogFilter) As ILogSaver
Set ILogSaver_AddFilter = Me.AddFilter(TheFilter)
End Function
Private Property Get ILogSaver_ID() As Long
ILogSaver_ID = Me.ID
End Property
Private Property Get ILogSaver_Name() As String
ILogSaver_Name = Me.Name
End Property
Private Property Let ILogSaver_Name(ByVal TheName As String)
Me.Name = TheName
End Property
Private Sub ILogSaver_SaveToLog(objLogEntry As clsLogEntry)
Call Me.SaveToLog(objLogEntry)
End Sub
' ---------------------------------------------------------------------------------
' -- Specific Functions for that logger here
Private Sub SaveToMyLog(ByRef objLogEntry As clsLogEntry)
' ToDo: Implement your functionality here
End Sub