From 40d80fe297e9a800dbf281dd95b6a931af629c4c Mon Sep 17 00:00:00 2001 From: David Coutadeur Date: Fri, 12 Jul 2024 18:58:20 +0200 Subject: [PATCH] adapt log level for stdout/stderr msg sent by posthook (#262) --- src/main/java/org/lsc/Hooks.java | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/lsc/Hooks.java b/src/main/java/org/lsc/Hooks.java index f8aa0a36..ab4f4b61 100644 --- a/src/main/java/org/lsc/Hooks.java +++ b/src/main/java/org/lsc/Hooks.java @@ -41,6 +41,7 @@ */ package org.lsc; +import org.slf4j.event.Level; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.lang.ProcessBuilder; @@ -125,13 +126,15 @@ public final static void callHook( LscModificationType operationType, operationType.getDescription(), hook, outputFormat.toString(), - identifier); + identifier, + Level.INFO); printHookOutput(p.getErrorStream(), "stderr", operationType.getDescription(), hook, outputFormat.toString(), - identifier); + identifier, + Level.ERROR); } catch(IOException e) { LOGGER.error("Error while calling {} posthook {} with format {} for {}", @@ -162,18 +165,20 @@ public final static String getJsonModifications(final LscModifications lm) { private static void printHookOutput( final InputStream src, String output, String operation, String hook, - String outputFormat, String identifier) { + String outputFormat, String identifier, + Level level) { new Thread(new Runnable() { public void run() { Scanner sc = new Scanner(src); while (sc.hasNextLine()) { - LOGGER.warn("Hook {} with format {} for identifier {} and operation {} returned {}: {}", - hook, - outputFormat, - identifier, - operation, - output, - sc.nextLine()); + LOGGER.atLevel(level).log( + "Hook {} with format {} for identifier {} and operation {} returned on {}: {}", + hook, + outputFormat, + identifier, + operation, + output, + sc.nextLine()); } } }).start();