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