org.ops4j.pax.logging.spi.PaxLevel Maven / Gradle / Ivy
Go to download
Pax Logging API Library is a collection of logging APIs from different libraries/facades.
It supports SLF4J, Commons Logging, JULI Logging, Log4J1 API, Log4J2 API, JBoss Logging and Avalon APIs.
Additionally, Pax Logging specific library is available as backend implementation with its specific configuration mechanisms,
but it's not required.
The newest version!
/*
* Copyright 2006 Niclas Hedhman.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
* implied.
*
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.ops4j.pax.logging.spi;
import org.osgi.service.log.LogLevel;
/**
* Framework library agnostic representation of logging level. There are two uses of level
* concept:
*
* - detail level or importance of logging event
* - threshold of the logging service, appender or destination, that allows to process or reject logging events
* with some level
*
*
* Terms like higher or lower may be confusing at first glance. Each framework may use different
* numerical levels than other. Syslog and {@link org.osgi.service.log.LogService} use higher numerical values for less
* important logging events. Log4J1 and {@code java.util.logging} use higher numerical values for more important events.
*
* This interface is based on Log4J1 and:
*
* - the higher value (numerically) the more important the event is (higher severity)
* - {@code INFO} is higher than {@code DEBUG}
* - when used as threshold, PaxLevel=INFO rejects events with level=DEBUG and level=TRACE.
* - also, the higher the threshold the more events are rejected (less are processed).
*
*/
public interface PaxLevel {
/**
* Returns true
if this level has a higher or equal level (is more important,
* has bigger severity) than the level passed as argument, false
otherwise.
*
* @param r the PaxLevel to compare with.
* @return true if this level has a higher or equal level than the level passed as argument, false
otherwise.
*/
boolean isGreaterOrEqual(PaxLevel r);
/**
* Returns {@link LogLevel} representation of this level. In {@link LogLevel} enum, the higher the numerical
* value (ordinal of the enum), the less important is the logging event with given level. When used as
* threshold, the higher the numerical value, the less events are rejected (i.e., high threshold
* means process even less important events).
*/
LogLevel toLevel();
/**
* Return the syslog equivalent of this priority as an integer. In Syslog
* (https://en.wikipedia.org/wiki/Syslog#Severity_level), higher numerical values indicate less important
* logging events.
*
* @return the syslog equivalent of this priority as an integer.
*/
int getSyslogEquivalent();
}