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

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

リスナオブジェクトをオブジェクトポインタではなくオブジェクトとして管理するようにした。

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