X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=policy-agent%2Fsrc%2Ftest%2Fjava%2Forg%2Foransc%2Fpolicyagent%2Futils%2FLoggingUtils.java;h=a594091873d9ae1e1db31756b0310ef7068239bc;hb=7ab83b874b5118ce9bbbbcab2c010c1d5f17ba98;hp=a822bb35d4361419ab395329c0500d6827cd6201;hpb=6fe1880bfac3daa86c05461da80147325f5f47a2;p=nonrtric.git diff --git a/policy-agent/src/test/java/org/oransc/policyagent/utils/LoggingUtils.java b/policy-agent/src/test/java/org/oransc/policyagent/utils/LoggingUtils.java index a822bb35..a5940918 100644 --- a/policy-agent/src/test/java/org/oransc/policyagent/utils/LoggingUtils.java +++ b/policy-agent/src/test/java/org/oransc/policyagent/utils/LoggingUtils.java @@ -30,23 +30,27 @@ import org.slf4j.LoggerFactory; public class LoggingUtils { /** - * Returns a ListAppender that contains all logging events. Call this method at the very beginning of the test + * Returns a ListAppender that contains all logging events. Call this method right before calling the tested + * method. + * + * @return the log list appender for the given class. */ public static ListAppender getLogListAppender(Class logClass) { - return getLogListAppender(logClass, false); + return getLogListAppender(logClass, Level.ALL); } /** - * Returns a ListAppender that contains all logging events. Call this method at the very beginning of the test + * Returns a ListAppender that contains events for the given level. Call this method right before calling the tested + * method. * * @param logClass class whose appender is wanted. - * @param allLevels true if all log levels should be activated. + * @param level the log level to log at. + * + * @return the log list appender for the given class logging on the given level. */ - public static ListAppender getLogListAppender(Class logClass, boolean allLevels) { + public static ListAppender getLogListAppender(Class logClass, Level level) { Logger logger = (Logger) LoggerFactory.getLogger(logClass); - if (allLevels) { - logger.setLevel(Level.ALL); - } + logger.setLevel(level); ListAppender listAppender = new ListAppender<>(); listAppender.start(); logger.addAppender(listAppender);