Skip to content

Commit 89ac135

Browse files
committed
Enable debug logging earlier in GenerateCommand
1 parent d4c298a commit 89ac135

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/java/com/endava/cats/command/GenerateCommand.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
import com.endava.cats.http.HttpMethod;
66
import com.endava.cats.model.FuzzingData;
77
import com.endava.cats.openapi.OpenApiUtils;
8-
import com.endava.cats.util.CatsUtil;
98
import com.endava.cats.util.JsonUtils;
109
import com.endava.cats.util.VersionProvider;
1110
import com.google.gson.JsonParser;
1211
import io.github.ludovicianul.prettylogger.PrettyLogger;
1312
import io.github.ludovicianul.prettylogger.PrettyLoggerFactory;
13+
import io.github.ludovicianul.prettylogger.config.level.PrettyLevel;
1414
import io.quarkus.arc.Unremovable;
1515
import io.swagger.v3.oas.models.OpenAPI;
1616
import io.swagger.v3.oas.models.PathItem;
@@ -89,12 +89,14 @@ public GenerateCommand(FuzzingDataFactory fuzzingDataFactory, CatsGlobalContext
8989
@Override
9090
public void run() {
9191
try {
92+
if (!debug) {
93+
PrettyLogger.enableLevels(PrettyLevel.CONFIG, PrettyLevel.FATAL);
94+
}
95+
9296
OpenAPI openAPI = OpenApiUtils.readOpenApi(contract);
9397
this.checkOpenAPI(openAPI);
9498
this.globalContext.init(openAPI, List.of(contentType), new Properties());
95-
if (debug) {
96-
CatsUtil.setCatsLogLevel("ALL");
97-
}
99+
98100
PathItem pathItem = openAPI.getPaths().entrySet()
99101
.stream().filter(openApiPath -> openApiPath.getKey().equalsIgnoreCase(path))
100102
.map(Map.Entry::getValue).findFirst().orElseThrow(() -> new IllegalArgumentException("Provided path does not exist!"));
@@ -107,7 +109,7 @@ public void run() {
107109
printResult(filteredBasedOnHttpMethod.stream().map(FuzzingData::getPayload).toList());
108110
} catch (IOException | IllegalArgumentException e) {
109111
logger.fatal("Something went wrong while running CATS: {}", e.toString());
110-
logger.debug("Stacktrace", e);
112+
logger.debug("Stacktrace: {}", e);
111113
exitCodeDueToErrors = 192;
112114
}
113115
}

0 commit comments

Comments
 (0)