1 |
|
---|
2 | Class _System_TraceBase
|
---|
3 | indentLevel As Long
|
---|
4 | indentSize As Long
|
---|
5 |
|
---|
6 |
|
---|
7 | ' リスナ管理
|
---|
8 | listeners As TraceListenerCollection
|
---|
9 |
|
---|
10 | Public
|
---|
11 |
|
---|
12 | ' コンストラクタ
|
---|
13 | Sub _System_TraceBase()
|
---|
14 | listeners = New TraceListenerCollection
|
---|
15 | listeners.Add( New DefaultTraceListener() )
|
---|
16 |
|
---|
17 | indentLevel = 0
|
---|
18 | indentSize = 4
|
---|
19 | End Sub
|
---|
20 |
|
---|
21 | '----------------------------------------------------------------
|
---|
22 | ' パブリック メソッド
|
---|
23 | '----------------------------------------------------------------
|
---|
24 |
|
---|
25 | ' アサート(コールスタックを表示)
|
---|
26 | Sub Assert( condition As Boolean )
|
---|
27 | If condition = False then
|
---|
28 | 'TODO: コールスタックを表示
|
---|
29 | End If
|
---|
30 | End Sub
|
---|
31 |
|
---|
32 | ' アサート(メッセージ文字列を表示)
|
---|
33 | Sub Assert( condition As Boolean, message As String )
|
---|
34 | If condition = False then
|
---|
35 | ' TODO: メッセージボックス形式での表示に対応
|
---|
36 | WriteLine( message )
|
---|
37 | End If
|
---|
38 | End Sub
|
---|
39 |
|
---|
40 | ' アサート(メッセージ文字列と詳細文字列を表示)
|
---|
41 | Sub Assert( condition As Boolean, message As String, detailMessage As String )
|
---|
42 | If condition = False then
|
---|
43 | ' TODO: メッセージボックス形式での表示に対応
|
---|
44 | WriteLine( message )
|
---|
45 | End If
|
---|
46 | End Sub
|
---|
47 |
|
---|
48 |
|
---|
49 | ' インデントレベルを上げる
|
---|
50 | Sub Indent()
|
---|
51 | IndentLevel = indentLevel + 1
|
---|
52 | End Sub
|
---|
53 |
|
---|
54 | ' インデントレベルを下げる
|
---|
55 | Sub Unindent()
|
---|
56 | If indentLevel <= 0 Then
|
---|
57 | indentLevel = 0
|
---|
58 | Return
|
---|
59 | End If
|
---|
60 | IndentLevel = indentLevel - 1
|
---|
61 | End Sub
|
---|
62 |
|
---|
63 | ' 文字列を出力
|
---|
64 | Sub Write( value As Object )
|
---|
65 | Dim i As Long
|
---|
66 | For i = 0 To ELM( listeners.Count )
|
---|
67 | Dim listener = listeners[i]
|
---|
68 | listener.Write( value )
|
---|
69 | Next
|
---|
70 | End Sub
|
---|
71 | Sub Write( message As String )
|
---|
72 | Dim i As Long
|
---|
73 | For i = 0 To ELM( listeners.Count )
|
---|
74 | Dim listener = listeners[i]
|
---|
75 | listener.Write( message )
|
---|
76 | Next
|
---|
77 | End Sub
|
---|
78 | Sub Write( value As Object, category As String )
|
---|
79 | Dim i As Long
|
---|
80 | For i = 0 To ELM( listeners.Count )
|
---|
81 | Dim listener = listeners[i]
|
---|
82 | listener.Write( value, category )
|
---|
83 | Next
|
---|
84 | End Sub
|
---|
85 | Sub Write( message As String, category As String )
|
---|
86 | Dim i As Long
|
---|
87 | For i = 0 To ELM( listeners.Count )
|
---|
88 | Dim listener = listeners[i]
|
---|
89 | listener.Write( message, category )
|
---|
90 | Next
|
---|
91 | End Sub
|
---|
92 |
|
---|
93 | ' 一行の文字列を出力
|
---|
94 | Sub WriteLine( value As Object )
|
---|
95 | Dim i As Long
|
---|
96 | For i = 0 To ELM( listeners.Count )
|
---|
97 | Dim listener = listeners[i]
|
---|
98 | listener.WriteLine( value )
|
---|
99 | Next
|
---|
100 | End Sub
|
---|
101 | Sub WriteLine( message As String )
|
---|
102 | Dim i As Long
|
---|
103 | For i = 0 To ELM( listeners.Count )
|
---|
104 | Dim listener = listeners[i]
|
---|
105 | listener.WriteLine( message )
|
---|
106 | Next
|
---|
107 | End Sub
|
---|
108 | Sub WriteLine( value As Object, category As String )
|
---|
109 | Dim i As Long
|
---|
110 | For i = 0 To ELM( listeners.Count )
|
---|
111 | Dim listener = listeners[i]
|
---|
112 | listener.WriteLine( value, category )
|
---|
113 | Next
|
---|
114 | End Sub
|
---|
115 | Sub WriteLine( message As String, category As String )
|
---|
116 | Dim i As Long
|
---|
117 | For i = 0 To ELM( listeners.Count )
|
---|
118 | Dim listener = listeners[i]
|
---|
119 | listener.WriteLine( message, category )
|
---|
120 | Next
|
---|
121 | End Sub
|
---|
122 |
|
---|
123 | ' 条件をもとに文字列を出力
|
---|
124 | Sub WriteIf( condition As Boolean, value As Object )
|
---|
125 | Dim i As Long
|
---|
126 | For i = 0 To ELM( listeners.Count )
|
---|
127 | Dim listener = listeners[i]
|
---|
128 | listener.WriteIf( condition, value )
|
---|
129 | Next
|
---|
130 | End Sub
|
---|
131 | Sub WriteIf( condition As Boolean, message As String )
|
---|
132 | Dim i As Long
|
---|
133 | For i = 0 To ELM( listeners.Count )
|
---|
134 | Dim listener = listeners[i]
|
---|
135 | listener.WriteIf( condition, message )
|
---|
136 | Next
|
---|
137 | End Sub
|
---|
138 | Sub WriteIf( condition As Boolean, value As Object, category As String )
|
---|
139 | Dim i As Long
|
---|
140 | For i = 0 To ELM( listeners.Count )
|
---|
141 | Dim listener = listeners[i]
|
---|
142 | listener.WriteIf( condition, value, category )
|
---|
143 | Next
|
---|
144 | End Sub
|
---|
145 | Sub WriteIf( condition As Boolean, message As String, category As String )
|
---|
146 | Dim i As Long
|
---|
147 | For i = 0 To ELM( listeners.Count )
|
---|
148 | Dim listener = listeners[i]
|
---|
149 | listener.WriteIf( condition, message, category )
|
---|
150 | Next
|
---|
151 | End Sub
|
---|
152 |
|
---|
153 | ' 条件をもとに一行の文字列を出力
|
---|
154 | Sub WriteLineIf( condition As Boolean, value As Object )
|
---|
155 | Dim i As Long
|
---|
156 | For i = 0 To ELM( listeners.Count )
|
---|
157 | Dim listener = listeners[i]
|
---|
158 | listener.WriteLineIf( condition, value )
|
---|
159 | Next
|
---|
160 | End Sub
|
---|
161 | Sub WriteLineIf( condition As Boolean, message As String )
|
---|
162 | Dim i As Long
|
---|
163 | For i = 0 To ELM( listeners.Count )
|
---|
164 | Dim listener = listeners[i]
|
---|
165 | listener.WriteLineIf( condition, message )
|
---|
166 | Next
|
---|
167 | End Sub
|
---|
168 | Sub WriteLineIf( condition As Boolean, value As Object, category As String )
|
---|
169 | Dim i As Long
|
---|
170 | For i = 0 To ELM( listeners.Count )
|
---|
171 | Dim listener = listeners[i]
|
---|
172 | listener.WriteLineIf( condition, value, category )
|
---|
173 | Next
|
---|
174 | End Sub
|
---|
175 | Sub WriteLineIf( condition As Boolean, message As String, category As String )
|
---|
176 | Dim i As Long
|
---|
177 | For i = 0 To ELM( listeners.Count )
|
---|
178 | Dim listener = listeners[i]
|
---|
179 | listener.WriteLineIf( condition, message, category )
|
---|
180 | Next
|
---|
181 | End Sub
|
---|
182 |
|
---|
183 |
|
---|
184 | '----------------------------------------------------------------
|
---|
185 | ' パブリック プロパティ
|
---|
186 | '----------------------------------------------------------------
|
---|
187 |
|
---|
188 | ' IndentLevelプロパティ
|
---|
189 | Function IndentLevel() As Long
|
---|
190 | Return indentLevel
|
---|
191 | End Function
|
---|
192 | Sub IndentLevel( indentLevel As Long )
|
---|
193 | This.indentLevel = indentLevel
|
---|
194 |
|
---|
195 | Dim i As Long
|
---|
196 | For i = 0 To ELM( listeners.Count )
|
---|
197 | Dim listener = listeners[i]
|
---|
198 | listener.IndentLevel = indentLevel
|
---|
199 | Next
|
---|
200 | End Sub
|
---|
201 |
|
---|
202 | ' IndentSizeプロパティ
|
---|
203 | Function IndentSize() As Long
|
---|
204 | Return indentSize
|
---|
205 | End Function
|
---|
206 | Sub IndentSize( size As Long )
|
---|
207 | indentSize = size
|
---|
208 |
|
---|
209 | Dim i As Long
|
---|
210 | For i = 0 To ELM( listeners.Count )
|
---|
211 | Dim listener = listeners[i]
|
---|
212 | listener.IndentSize = indentSize
|
---|
213 | Next
|
---|
214 | End Sub
|
---|
215 |
|
---|
216 | ' Listenersプロパティ
|
---|
217 | Function Listeners() As TraceListenerCollection
|
---|
218 | Return listeners
|
---|
219 | End Function
|
---|
220 |
|
---|
221 | End Class
|
---|
222 |
|
---|