1
1
using System ;
2
+ using System . Diagnostics ;
2
3
using System . Xml ;
3
4
using System . Xml . Linq ;
4
5
@@ -7,7 +8,7 @@ namespace Java.Interop.Tools.Generator
7
8
public class Report
8
9
{
9
10
public static int ? Verbosity { get ; set ; }
10
- public static Action < string > ? OutputDelegate { get ; set ; }
11
+ public static Action < TraceLevel , string > ? OutputDelegate { get ; set ; }
11
12
12
13
public class LocalizedMessage
13
14
{
@@ -97,7 +98,7 @@ public static void LogCodedError (LocalizedMessage message, XNode? node, params
97
98
98
99
public static void LogCodedError ( LocalizedMessage message , string ? sourceFile , int line , int column , params string ? [ ] args )
99
100
{
100
- WriteOutput ( Format ( true , message . Code , sourceFile , line , column , message . Value , args ) ) ;
101
+ WriteOutput ( TraceLevel . Error , Format ( true , message . Code , sourceFile , line , column , message . Value , args ) ) ;
101
102
}
102
103
103
104
public static void LogCodedWarning ( int verbosity , LocalizedMessage message , params string ? [ ] args )
@@ -122,17 +123,17 @@ public static void LogCodedWarning (int verbosity, LocalizedMessage message, Exc
122
123
return ;
123
124
124
125
var supp = innerException != null ? " For details, see verbose output." : null ;
125
- WriteOutput ( Format ( false , message . Code , sourceFile , line , column , message . Value , args ) + supp ) ;
126
+ WriteOutput ( TraceLevel . Warning , Format ( false , message . Code , sourceFile , line , column , message . Value , args ) + supp ) ;
126
127
127
128
if ( innerException != null )
128
- WriteOutput ( innerException . ToString ( ) ) ;
129
+ WriteOutput ( TraceLevel . Warning , innerException . ToString ( ) ) ;
129
130
}
130
131
131
132
public static void Verbose ( int verbosity , string format , params object ? [ ] args )
132
133
{
133
134
if ( verbosity > ( Verbosity ?? 0 ) )
134
135
return ;
135
- WriteOutput ( format , args ) ;
136
+ WriteOutput ( TraceLevel . Verbose , format , args ) ;
136
137
}
137
138
138
139
public static string FormatCodedMessage ( bool error , LocalizedMessage message , params object ? [ ] args )
@@ -172,11 +173,11 @@ public static string Format (bool error, int errorCode, string? sourceFile, int
172
173
return ( file , pos ? . LineNumber ?? - 1 , pos ? . LinePosition ?? - 1 ) ;
173
174
}
174
175
175
- static void WriteOutput ( string format , params object ? [ ] args )
176
+ static void WriteOutput ( TraceLevel traceLevel , string format , params object ? [ ] args )
176
177
{
177
178
// Write to overridden output if requested
178
179
if ( OutputDelegate != null ) {
179
- OutputDelegate ( string . Format ( format , args ) ) ;
180
+ OutputDelegate ( traceLevel , string . Format ( format , args ) ) ;
180
181
return ;
181
182
}
182
183
0 commit comments