Skip to content

Commit

Permalink
added LevelUtil
Browse files Browse the repository at this point in the history
Signed-off-by: Ceki Gulcu <[email protected]>
  • Loading branch information
ceki committed Feb 26, 2024
1 parent 9c65d2d commit 6dc07a2
Showing 1 changed file with 50 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
package ch.qos.logback.classic.util;public class LevelUtil {
/*
* Logback: the reliable, generic, fast and flexible logging framework.
* Copyright (C) 1999-2024, QOS.ch. All rights reserved.
*
* This program and the accompanying materials are dual-licensed under
* either the terms of the Eclipse Public License v1.0 as published by
* the Eclipse Foundation
*
* or (per the licensee's choosing)
*
* under the terms of the GNU Lesser General Public License version 2.1
* as published by the Free Software Foundation.
*/

package ch.qos.logback.classic.util;

import ch.qos.logback.classic.Level;
import ch.qos.logback.core.joran.JoranConstants;
import ch.qos.logback.core.util.OptionHelper;

import static ch.qos.logback.core.joran.JoranConstants.NULL;

/**
*
* Utility methods for transforming string values to Level.
*
* @since 1.5.1
*/
public class LevelUtil {


public static boolean isInheritedLevelString(String levelStr) {
if (JoranConstants.INHERITED.equalsIgnoreCase(levelStr) || NULL.equalsIgnoreCase(levelStr)) {
return true;
} else
return false;
}

public static Level levelStringToLevel(String levelStr) {
if (!OptionHelper.isNullOrEmptyOrAllSpaces(levelStr)) {
if (isInheritedLevelString(levelStr)) {
return null;
} else {
Level level = Level.toLevel(levelStr);
return level;
}
}
return null;
}

}

0 comments on commit 6dc07a2

Please sign in to comment.