[69] | 1 |
|
---|
| 2 | Class _System_TraceBase
|
---|
[79] | 3 | indentLevel As Long
|
---|
| 4 | indentSize As Long
|
---|
[69] | 5 |
|
---|
| 6 |
|
---|
| 7 | ' リスナ管理
|
---|
| 8 | listeners As TraceListenerCollection
|
---|
| 9 |
|
---|
| 10 | Public
|
---|
| 11 |
|
---|
| 12 | ' コンストラクタ
|
---|
| 13 | Sub _System_TraceBase()
|
---|
| 14 | Dim _System_defaultTraceListener As DefaultTraceListener
|
---|
| 15 | listeners.Add( _System_defaultTraceListener )
|
---|
[79] | 16 |
|
---|
| 17 | indentLevel = 0
|
---|
| 18 | indentSize = 4
|
---|
[69] | 19 | End Sub
|
---|
| 20 |
|
---|
| 21 | '----------------------------------------------------------------
|
---|
| 22 | ' パブリック メソッド
|
---|
| 23 | '----------------------------------------------------------------
|
---|
| 24 |
|
---|
| 25 | ' アサート(コールスタックを表示)
|
---|
| 26 | Sub Assert( condition As Boolean )
|
---|
[87] | 27 | If condition = False then
|
---|
[69] | 28 | 'TODO: コールスタックを表示
|
---|
| 29 | End If
|
---|
| 30 | End Sub
|
---|
| 31 |
|
---|
| 32 | ' アサート(メッセージ文字列を表示)
|
---|
| 33 | Sub Assert( condition As Boolean, message As String )
|
---|
[87] | 34 | If condition = False then
|
---|
[69] | 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 )
|
---|
[108] | 42 | If condition = False then
|
---|
[69] | 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 )
|
---|
[79] | 67 | Dim ByRef listener = listeners[i]
|
---|
| 68 | listener.Write( value )
|
---|
[69] | 69 | Next
|
---|
| 70 | End Sub
|
---|
| 71 | Sub Write( message As String )
|
---|
| 72 | Dim i As Long
|
---|
| 73 | For i = 0 To ELM( listeners.Count )
|
---|
[79] | 74 | Dim ByRef listener = listeners[i]
|
---|
| 75 | listener.Write( message )
|
---|
[69] | 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 )
|
---|
[79] | 81 | Dim ByRef listener = listeners[i]
|
---|
| 82 | listener.Write( value, category )
|
---|
[69] | 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 )
|
---|
[79] | 88 | Dim ByRef listener = listeners[i]
|
---|
| 89 | listener.Write( message, category )
|
---|
[69] | 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 )
|
---|
[79] | 97 | Dim ByRef listener = listeners[i]
|
---|
| 98 | listener.WriteLine( value )
|
---|
[69] | 99 | Next
|
---|
| 100 | End Sub
|
---|
| 101 | Sub WriteLine( message As String )
|
---|
| 102 | Dim i As Long
|
---|
| 103 | For i = 0 To ELM( listeners.Count )
|
---|
[79] | 104 | Dim ByRef listener = listeners[i]
|
---|
| 105 | listener.WriteLine( message )
|
---|
[69] | 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 )
|
---|
[79] | 111 | Dim ByRef listener = listeners[i]
|
---|
| 112 | listener.WriteLine( value, category )
|
---|
[69] | 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 )
|
---|
[79] | 118 | Dim ByRef listener = listeners[i]
|
---|
| 119 | listener.WriteLine( message, category )
|
---|
[69] | 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 )
|
---|
[79] | 127 | Dim ByRef listener = listeners[i]
|
---|
| 128 | listener.WriteIf( condition, value )
|
---|
[69] | 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 )
|
---|
[79] | 134 | Dim ByRef listener = listeners[i]
|
---|
| 135 | listener.WriteIf( condition, message )
|
---|
[69] | 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 )
|
---|
[79] | 141 | Dim ByRef listener = listeners[i]
|
---|
| 142 | listener.WriteIf( condition, value, category )
|
---|
[69] | 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 )
|
---|
[79] | 148 | Dim ByRef listener = listeners[i]
|
---|
| 149 | listener.WriteIf( condition, message, category )
|
---|
[69] | 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 )
|
---|
[79] | 157 | Dim ByRef listener = listeners[i]
|
---|
| 158 | listener.WriteLineIf( condition, value )
|
---|
[69] | 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 )
|
---|
[79] | 164 | Dim ByRef listener = listeners[i]
|
---|
| 165 | listener.WriteLineIf( condition, message )
|
---|
[69] | 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 )
|
---|
[79] | 171 | Dim ByRef listener = listeners[i]
|
---|
| 172 | listener.WriteLineIf( condition, value, category )
|
---|
[69] | 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 )
|
---|
[79] | 178 | Dim ByRef listener = listeners[i]
|
---|
| 179 | listener.WriteLineIf( condition, message, category )
|
---|
[69] | 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 )
|
---|
[79] | 197 | Dim ByRef listener = listeners[i]
|
---|
| 198 | listener.IndentLevel = indentLevel
|
---|
[69] | 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 )
|
---|
[79] | 211 | Dim ByRef listener = listeners[i]
|
---|
| 212 | listener.IndentSize = indentSize
|
---|
[69] | 213 | Next
|
---|
| 214 | End Sub
|
---|
| 215 |
|
---|
| 216 | ' Listenersプロパティ
|
---|
| 217 | Function Listeners() As TraceListenerCollection
|
---|
| 218 | Return listeners
|
---|
| 219 | End Function
|
---|
| 220 |
|
---|
| 221 | End Class
|
---|
| 222 |
|
---|