source: Include/Classes/System/Diagnostics/TraceListener.ab@ 246

Last change on this file since 246 was 246, checked in by dai, 17 years ago

Objectクラス、Stringクラスの定義をSystem名前空間に入れると共に、コンパイラ側で両者のクラスをSystem名前空間に依存しない特殊型として扱うようにした。
System.Diagnostics名前空間を導入した。
Namespaceステートメントのコード補間機能に対応。

File size: 2.8 KB
RevLine 
[246]1Namespace System
2 Namespace Diagnostics
[58]3
[246]4 ' リスナ
5 Class TraceListener
6 indentLevel As Long
7 indentSize As Long
[58]8
[246]9 Protected
10 Function GetIndentString() As String
11 Dim i As Long
[58]12
[246]13 Dim IndentStr = ""
14 For i = 0 To ELM( indentSize )
15 IndentStr = IndentStr + " "
16 Next
[58]17
[246]18 Dim ResultStr = ""
19 For i = 0 To ELM( indentLevel )
20 ResultStr = ResultStr + IndentStr
21 Next
[58]22
[246]23 Return ResultStr
24 End Function
[58]25
[246]26 Public
27 Sub TraceListener()
28 indentLevel = 0
29 indentSize = 4
30 End Sub
[58]31
[246]32 ' コピーコンストラクタ
33 Sub TraceListener( ByRef listener As TraceListener )
34 indentLevel = listener.indentLevel
35 indentSize = listener.indentSize
36 End Sub
[58]37
38
[246]39 '----------------------------------------------------------------
40 ' パブリック コンストラクタ
41 '----------------------------------------------------------------
[58]42
[246]43 Virtual Sub Write( message As String )
44 '派生クラスで実装 (基底では何もしない)
45 End Sub
46 Virtual Sub Write( value As Object )
47 Write( value.ToString() )
48 End Sub
49 Virtual Sub Write( value As Object, category As String )
50 Write( category + ": " + value.ToString() )
51 End Sub
52 Virtual Sub Write( message As String, category As String )
53 Write( category + ": " + message )
54 End Sub
[58]55
[246]56 Virtual Sub WriteLine( message As String )
57 '派生クラスで実装 (基底では何もしない)
58 End Sub
59 Virtual Sub WriteLine( value As Object )
60 WriteLine( value.ToString() )
61 End Sub
62 Virtual Sub WriteLine( value As Object, category As String )
63 WriteLine( category + ": " + value.ToString() )
64 End Sub
65 Virtual Sub WriteLine( message As String, category As String )
66 WriteLine( category + ": " + message )
67 End Sub
[58]68
69
[246]70 '----------------------------------------------------------------
71 ' パブリック プロパティ
72 '----------------------------------------------------------------
[58]73
[246]74 ' IndentLevelプロパティ
75 Function IndentLevel() As Long
76 Return indentLevel
77 End Function
78 Sub IndentLevel( indentLevel As Long )
79 This.indentLevel = indentLevel
80 End Sub
[58]81
[246]82 ' IndentSizeプロパティ
83 Function IndentSize() As Long
84 Return indentSize
85 End Function
86 Sub IndentSize( size As Long )
87 indentSize = size
88 End Sub
89 End Class
[58]90
[246]91 ' デフォルトリスナ(デバッガビューへの出力)
92 Class DefaultTraceListener
93 Inherits TraceListener
94 Public
[58]95
[246]96 Override Sub Write( message As String )
97 ' デバッグビューへ出力
98 Dim tempStr = GetIndentString() + message
99 OutputDebugString( tempStr )
[58]100
[246]101 ' デバッグログへ書き込む
102 ' TODO: 実装
103 End Sub
[58]104
[246]105 Override Sub WriteLine( message As String )
106 Write( GetIndentString() + message + Ex"\r\n" )
107 End Sub
108 End Class
109
110 End Namespace
111End Namespace
Note: See TracBrowser for help on using the repository browser.