X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db.common%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fcommon%2Futils%2FLogManager.java;h=9abae439d75932653a8907e28a3803d940d7ca0f;hp=be878990dc13f38f6180adfb81c8e0ea23a3f559;hb=25e3207c8a1aad3cbe72202750f67f0483ccb1a2;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/LogManager.java b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/LogManager.java index be878990d..9abae439d 100644 --- a/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/LogManager.java +++ b/bundles/org.simantics.db.common/src/org/simantics/db/common/utils/LogManager.java @@ -1,151 +1,151 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.db.common.utils; - -import java.util.Properties; - -import org.apache.log4j.Hierarchy; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PropertyConfigurator; -import org.apache.log4j.spi.LoggerFactory; -import org.apache.log4j.spi.RootLogger; - -/** - * This class encapsulates a Log4J Hierarchy and centralizes all Logger access. - */ -public class LogManager { - - private Hierarchy hierarchy; - - /** - * Creates a new LogManager. Saves the log and state location. - * Creates a new Hierarchy and add a new EventListener to it. - * Configure the hierarchy with the properties passed. Add this object to - * the list of active log managers. - * - * @param properties log configuration properties - */ - public LogManager(Properties properties) { - this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG)); - new PropertyConfigurator().doConfigure(properties, this.hierarchy); - } - - /** - * Checks if this PluginLogManager is disabled for this level. - * - * @param level level value - * @return boolean true if it is disabled - */ - public boolean isDisabled(int level) { - return this.hierarchy.isDisabled(level); - } - - /** - * Enable logging for logging requests with level l or higher. By default - * all levels are enabled. - * - * @param level level object - */ - public void setThreshold(Level level) { - this.hierarchy.setThreshold(level); - } - - /** - * The string version of setThreshold(Level level) - * - * @param level level string - */ - public void setThreshold(String level) { - this.hierarchy.setThreshold(level); - } - - /** - * Get the repository-wide threshold. - * - * @return Level - */ - public Level getThreshold() { - return this.hierarchy.getThreshold(); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param clazz the class to get the logger for - * @return Logger - */ - public Logger getLogger(Class clazz) { - return this.hierarchy.getLogger(clazz.getName()); - } - - /** - * Returns a new logger instance named as the first parameter using the - * default factory. If a logger of that name already exists, then it will be - * returned. Otherwise, a new logger will be instantiated and then linked - * with its existing ancestors as well as children. - * - * @param name logger name - * @return Logger - */ - public Logger getLogger(String name) { - return this.hierarchy.getLogger(name); - } - - /** - * The same as getLogger(String name) but using a factory instance instead - * of a default factory. - * - * @param name logger name - * @param factory factory instance - * @return Logger - */ - public Logger getLogger(String name, LoggerFactory factory) { - return this.hierarchy.getLogger(name, factory); - } - - /** - * Returns the root of this hierarchy. - * - * @return Logger - */ - public Logger getRootLogger() { - return this.hierarchy.getRootLogger(); - } - - /** - * Checks if this logger exists. - * - * @return Logger - */ - public Logger exists(String name) { - return this.hierarchy.exists(name); - } - - /** - * Disposes the logger hierarchy - */ - public void shutdown() { - this.hierarchy.shutdown(); - } - - /** - * Resets configuration values to its defaults. - */ - public void resetConfiguration() { - this.hierarchy.resetConfiguration(); - } - +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.db.common.utils; + +import java.util.Properties; + +import org.apache.log4j.Hierarchy; +import org.apache.log4j.Level; +import org.apache.log4j.Logger; +import org.apache.log4j.PropertyConfigurator; +import org.apache.log4j.spi.LoggerFactory; +import org.apache.log4j.spi.RootLogger; + +/** + * This class encapsulates a Log4J Hierarchy and centralizes all Logger access. + */ +public class LogManager { + + private Hierarchy hierarchy; + + /** + * Creates a new LogManager. Saves the log and state location. + * Creates a new Hierarchy and add a new EventListener to it. + * Configure the hierarchy with the properties passed. Add this object to + * the list of active log managers. + * + * @param properties log configuration properties + */ + public LogManager(Properties properties) { + this.hierarchy = new Hierarchy(new RootLogger(Level.DEBUG)); + new PropertyConfigurator().doConfigure(properties, this.hierarchy); + } + + /** + * Checks if this PluginLogManager is disabled for this level. + * + * @param level level value + * @return boolean true if it is disabled + */ + public boolean isDisabled(int level) { + return this.hierarchy.isDisabled(level); + } + + /** + * Enable logging for logging requests with level l or higher. By default + * all levels are enabled. + * + * @param level level object + */ + public void setThreshold(Level level) { + this.hierarchy.setThreshold(level); + } + + /** + * The string version of setThreshold(Level level) + * + * @param level level string + */ + public void setThreshold(String level) { + this.hierarchy.setThreshold(level); + } + + /** + * Get the repository-wide threshold. + * + * @return Level + */ + public Level getThreshold() { + return this.hierarchy.getThreshold(); + } + + /** + * Returns a new logger instance named as the first parameter using the + * default factory. If a logger of that name already exists, then it will be + * returned. Otherwise, a new logger will be instantiated and then linked + * with its existing ancestors as well as children. + * + * @param clazz the class to get the logger for + * @return Logger + */ + public Logger getLogger(Class clazz) { + return this.hierarchy.getLogger(clazz.getName()); + } + + /** + * Returns a new logger instance named as the first parameter using the + * default factory. If a logger of that name already exists, then it will be + * returned. Otherwise, a new logger will be instantiated and then linked + * with its existing ancestors as well as children. + * + * @param name logger name + * @return Logger + */ + public Logger getLogger(String name) { + return this.hierarchy.getLogger(name); + } + + /** + * The same as getLogger(String name) but using a factory instance instead + * of a default factory. + * + * @param name logger name + * @param factory factory instance + * @return Logger + */ + public Logger getLogger(String name, LoggerFactory factory) { + return this.hierarchy.getLogger(name, factory); + } + + /** + * Returns the root of this hierarchy. + * + * @return Logger + */ + public Logger getRootLogger() { + return this.hierarchy.getRootLogger(); + } + + /** + * Checks if this logger exists. + * + * @return Logger + */ + public Logger exists(String name) { + return this.hierarchy.exists(name); + } + + /** + * Disposes the logger hierarchy + */ + public void shutdown() { + this.hierarchy.shutdown(); + } + + /** + * Resets configuration values to its defaults. + */ + public void resetConfiguration() { + this.hierarchy.resetConfiguration(); + } + } \ No newline at end of file