@@ -86,18 +86,13 @@ pub struct TraceInfo<T> {
86
86
#[ serde( flatten) ]
87
87
pub inner : T ,
88
88
}
89
+
89
90
impl TraceInfo < ( ) > {
90
91
// TODO: support more format?
91
- pub fn print ( & self , is_json : bool ) -> Option < String > {
92
+ pub fn print ( & self ) -> Option < String > {
92
93
match self . level {
93
94
Tracing :: Nothing => None ,
94
- Tracing :: Summary | Tracing :: Entity => {
95
- if is_json {
96
- Some ( serde_json:: to_string ( self ) . ok ( ) ?)
97
- } else {
98
- Some ( self . file_trace . print ( ) )
99
- }
100
- }
95
+ Tracing :: Summary | Tracing :: Entity => Some ( self . file_trace . print ( ) ) ,
101
96
}
102
97
}
103
98
@@ -112,20 +107,14 @@ impl TraceInfo<()> {
112
107
113
108
impl TraceInfo < RuleTrace > {
114
109
// TODO: support more format?
115
- pub fn print ( & self , is_json : bool ) -> Option < String > {
110
+ pub fn print ( & self ) -> Option < String > {
116
111
match self . level {
117
112
Tracing :: Nothing => None ,
118
- Tracing :: Summary | Tracing :: Entity => {
119
- if is_json {
120
- Some ( serde_json:: to_string ( self ) . ok ( ) ?)
121
- } else {
122
- Some ( format ! (
123
- "{}\n {}" ,
124
- self . file_trace. print( ) ,
125
- self . inner. print( )
126
- ) )
127
- }
128
- }
113
+ Tracing :: Summary | Tracing :: Entity => Some ( format ! (
114
+ "{}\n {}" ,
115
+ self . file_trace. print( ) ,
116
+ self . inner. print( )
117
+ ) ) ,
129
118
}
130
119
}
131
120
pub fn print_file (
@@ -181,7 +170,7 @@ mod test {
181
170
run_trace. file_trace. files_skipped. load( Ordering :: Relaxed ) ,
182
171
0
183
172
) ;
184
- let printed = run_trace. print ( false ) . expect ( "should have output" ) ;
173
+ let printed = run_trace. print ( ) . expect ( "should have output" ) ;
185
174
assert_eq ! ( printed, "Files scanned: 0, Files skipped: 0" ) ;
186
175
187
176
let rule_stats = RuleTrace {
@@ -200,7 +189,7 @@ mod test {
200
189
) ;
201
190
assert_eq ! ( scan_trace. inner. effective_rule_count, 10 ) ;
202
191
assert_eq ! ( scan_trace. inner. skipped_rule_count, 2 ) ;
203
- let printed = scan_trace. print ( false ) . expect ( "should have output" ) ;
192
+ let printed = scan_trace. print ( ) . expect ( "should have output" ) ;
204
193
assert_eq ! (
205
194
printed,
206
195
"Files scanned: 0, Files skipped: 0\n Effective rules: 10, Skipped rules: 2"
@@ -212,7 +201,7 @@ mod test {
212
201
let tracing = Tracing :: Nothing ;
213
202
let run_trace = tracing. run_trace ( ) ;
214
203
assert_eq ! ( run_trace. level, Tracing :: Nothing ) ;
215
- let printed = run_trace. print ( false ) ;
204
+ let printed = run_trace. print ( ) ;
216
205
assert ! ( printed. is_none( ) ) ;
217
206
}
218
207
}
0 commit comments