22
33import org .springframework .http .ResponseEntity ;
44import org .springframework .web .bind .annotation .GetMapping ;
5- import org .springframework .web .bind .annotation .PathVariable ;
6- import org .springframework .web .bind .annotation .RequestParam ;
75import org .springframework .web .bind .annotation .RestController ;
86
97import java .util .concurrent .atomic .AtomicInteger ;
1412public class EtwTestController {
1513 private static final DiagnosticsLoggerProxy DIAGNOSTICS_LOGGER = new DiagnosticsLoggerProxy ();
1614
15+ private static final String LEVEL = "info" ;
16+ private static final boolean HAS_EXCEPTION = false ;
17+
1718 private final AtomicInteger errorCount = new AtomicInteger ();
1819 private final AtomicInteger warnCount = new AtomicInteger ();
1920 private final AtomicInteger infoCount = new AtomicInteger ();
2021
21- @ GetMapping ("/{level}" )
22- public ResponseEntity <String > logPage (
23- @ PathVariable String level ,
24- @ RequestParam (name = "e" , required = false , defaultValue = "false" ) boolean hasException ) {
25- String msg = "Hit /" + level + " " ;
22+ @ GetMapping ("/log" )
23+ public ResponseEntity <String > logPage () {
24+ String msg = "Hit /" + LEVEL + " " ;
2625 int n ;
2726 Throwable t = null ;
28- switch (level .toLowerCase ()) {
27+ switch (LEVEL .toLowerCase ()) {
2928 case "info" :
3029 n = infoCount .incrementAndGet ();
3130 DIAGNOSTICS_LOGGER .info (msg + n );
3231 break ;
3332 case "error" :
3433 n = errorCount .incrementAndGet ();
35- if (hasException ) {
34+ if (HAS_EXCEPTION ) {
3635 t = new Exception ("the error " + n );
3736 DIAGNOSTICS_LOGGER .error (msg + n , t );
3837 } else {
@@ -41,7 +40,7 @@ public ResponseEntity<String> logPage(
4140 break ;
4241 case "warn" :
4342 n = warnCount .incrementAndGet ();
44- if (hasException ) {
43+ if (HAS_EXCEPTION ) {
4544 t = new Exception ("the warn " + n );
4645 DIAGNOSTICS_LOGGER .warn (msg + n , t );
4746 } else {
@@ -52,6 +51,6 @@ public ResponseEntity<String> logPage(
5251 return ResponseEntity .notFound ().build ();
5352 }
5453 return ResponseEntity .ok (
55- level .toUpperCase () + " " + n + (t == null ? "" : "<br/>\n " + t .toString ()));
54+ LEVEL .toUpperCase () + " " + n + (t == null ? "" : "<br/>\n " + t .toString ()));
5655 }
5756}
0 commit comments