source: trunk/Include/Classes/System/Diagnostics/TraceListener.ab@ 335

Last change on this file since 335 was 335, checked in by イグトランス (egtra), 17 years ago

SPrintF関連の追加。関数FloatToChars, FormatFloatE, FormatIntegerUと列挙体FormatFlags。

File size: 4.0 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 '----------------------------------------------------------------
[291]40 ' パブリック メソッド
[246]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
[290]69 ' 条件をもとに文字列を出力
70 Sub WriteIf( condition As Boolean, value As Object )
71 If condition Then
72 Write( value )
73 End If
74 End Sub
75 Sub WriteIf( condition As Boolean, message As String )
76 If condition Then
77 Write( message )
78 End If
79 End Sub
80 Sub WriteIf( condition As Boolean, value As Object, category As String )
81 If condition Then
82 Write( value, category )
83 End If
84 End Sub
85 Sub WriteIf( condition As Boolean, message As String, category As String )
86 If condition Then
87 Write( message, category )
88 End If
89 End Sub
[58]90
[291]91 ' 条件をもとに文字列を出力
92 Sub WriteLineIf( condition As Boolean, value As Object )
93 If condition Then
94 WriteLine( value )
95 End If
96 End Sub
97 Sub WriteLineIf( condition As Boolean, message As String )
98 If condition Then
99 WriteLine( message )
100 End If
101 End Sub
102 Sub WriteLineIf( condition As Boolean, value As Object, category As String )
103 If condition Then
104 WriteLine( value, category )
105 End If
106 End Sub
107 Sub WriteLineIf( condition As Boolean, message As String, category As String )
108 If condition Then
109 WriteLine( message, category )
110 End If
111 End Sub
[290]112
[291]113
[246]114 '----------------------------------------------------------------
115 ' パブリック プロパティ
116 '----------------------------------------------------------------
[58]117
[246]118 ' IndentLevelプロパティ
119 Function IndentLevel() As Long
120 Return indentLevel
121 End Function
122 Sub IndentLevel( indentLevel As Long )
123 This.indentLevel = indentLevel
124 End Sub
[58]125
[246]126 ' IndentSizeプロパティ
127 Function IndentSize() As Long
128 Return indentSize
129 End Function
130 Sub IndentSize( size As Long )
131 indentSize = size
132 End Sub
133 End Class
[58]134
[246]135 ' デフォルトリスナ(デバッガビューへの出力)
136 Class DefaultTraceListener
137 Inherits TraceListener
138 Public
[58]139
[246]140 Override Sub Write( message As String )
141 ' デバッグビューへ出力
142 Dim tempStr = GetIndentString() + message
[335]143 OutputDebugString( ToTCStr(tempStr) )
[58]144
[246]145 ' デバッグログへ書き込む
146 ' TODO: 実装
147 End Sub
[58]148
[246]149 Override Sub WriteLine( message As String )
150 Write( GetIndentString() + message + Ex"\r\n" )
151 End Sub
152 End Class
153
154 End Namespace
155End Namespace
Note: See TracBrowser for help on using the repository browser.