Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Modifications by Red Hat, Inc.
*
* This file incorporates work covered by the following notice(s):
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
/**
* @author Ceki Gülcü
* @author Anders Kristensen
*/
package org.apache.log4j;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.apache.log4j.helpers.NullEnumeration;
import org.apache.log4j.spi.AppenderAttachable;
import org.apache.log4j.spi.HierarchyEventListener;
import org.apache.log4j.spi.LoggerRepository;
import org.apache.log4j.spi.LoggingEvent;
public class Category implements AppenderAttachable {
private static final Object LEVEL_LOCK = new Object();
private static final String FQCN = Category.class.getName();
protected volatile Level level;
protected volatile Category parent;
final org.jboss.logmanager.Logger jblmLogger;
protected Category(String name) {
jblmLogger = JBossLogManagerFacade.getJBossLogger(name);
}
public void addAppender(Appender newAppender) {
Appenders.attachAppender(jblmLogger, newAppender);
getLoggerRepository().fireAddAppenderEvent(this, newAppender);
}
public void assertLog(boolean assertion, String msg) {
if (!assertion) error(msg);
}
public void callAppenders(LoggingEvent event) {
jblmLogger.logRaw(event.getLogRecord());
}
org.jboss.logmanager.Logger getJBossLogger() {
return jblmLogger;
}
void closeNestedAppenders() {
Appenders.closeAppenders(jblmLogger);
}
public void debug(Object message) {
if (jblmLogger.isLoggable(org.jboss.logmanager.Level.DEBUG)) {
forcedLog(FQCN, Level.DEBUG, message, null);
}
}
public void debug(Object message, Throwable t) {
if (jblmLogger.isLoggable(org.jboss.logmanager.Level.DEBUG)) {
forcedLog(FQCN, Level.DEBUG, message, t);
}
}
public void error(Object message) {
if (jblmLogger.isLoggable(org.jboss.logmanager.Level.ERROR)) {
forcedLog(FQCN, Level.ERROR, message, null);
}
}
public void error(Object message, Throwable t) {
if (jblmLogger.isLoggable(org.jboss.logmanager.Level.ERROR)) {
forcedLog(FQCN, Level.ERROR, message, t);
}
}
public static Logger exists(String name) {
return LogManager.exists(name);
}
public void fatal(Object message) {
if (jblmLogger.isLoggable(org.jboss.logmanager.Level.FATAL)) {
forcedLog(FQCN, Level.FATAL, message, null);
}
}
public void fatal(Object message, Throwable t) {
if (jblmLogger.isLoggable(org.jboss.logmanager.Level.FATAL)) {
forcedLog(FQCN, Level.FATAL, message, t);
}
}
protected void forcedLog(String fqcn, Priority level, Object message, Throwable t) {
callAppenders(new LoggingEvent(fqcn, this, level, message, t));
}
public boolean getAdditivity() {
return jblmLogger.getUseParentHandlers();
}
public Enumeration getAllAppenders() {
final List appenders = Appenders.getAppenders(jblmLogger);
if (appenders.isEmpty()) {
return NullEnumeration.getInstance();
}
return Collections.enumeration(appenders);
}
public Appender getAppender(String name) {
return Appenders.getAppender(jblmLogger, name);
}
public Level getEffectiveLevel() {
return JBossLevelMapping.getPriorityFor(jblmLogger.getEffectiveLevel());
}
@Deprecated
public Priority getChainedPriority() {
return getEffectiveLevel();
}
public static Enumeration getCurrentCategories() {
return LogManager.getCurrentLoggers();
}
@Deprecated
public static LoggerRepository getDefaultHierarchy() {
return LogManager.getLoggerRepository();
}
@Deprecated
public LoggerRepository getHierarchy() {
return getLoggerRepository();
}
public LoggerRepository getLoggerRepository() {
return LogManager.getLoggerRepository();
}
@Deprecated
public static Category getInstance(String name) {
return LogManager.getLogger(name);
}
@Deprecated
public static Category getInstance(Class clazz) {
return LogManager.getLogger(clazz);
}
public final String getName() {
return jblmLogger.getName();
}
public final Category getParent() {
return parent;
}
public final Level getLevel() {
synchronized (LEVEL_LOCK) {
if (level != null) {
// Check to see if the level was changed on the JBoss LogManger logger and set to match the current level
final Level currentLevel = JBossLevelMapping.getPriorityFor(jblmLogger.getLevel());
if (currentLevel.toInt() != level.toInt()) {
// It's likely this shouldn't happen, but to be safe we should run in a privilege block
if (System.getSecurityManager() == null) {
jblmLogger.setLevel(JBossLevelMapping.getLevelFor(level));
} else {
AccessController.doPrivileged(new PrivilegedAction