org.jfree.base.log.LogConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtstand-common Show documentation
Show all versions of jtstand-common Show documentation
jtstand-common is a library derived from jcommon, used by jtstand-chart, which is derived from jfreechart
/*
* Copyright (c) 2009 Albert Kurucz.
*
* This file, LogConfiguration.java is part of JTStand.
*
* JTStand is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* JTStand is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with GTStand. If not, see .
*/
package org.jfree.base.log;
import org.jfree.base.BaseBoot;
import org.jfree.util.PrintStreamLogTarget;
/**
* A log configuration class. This implementation is a simple frontend
* to the global configuration.
*
* @author Thomas Morgner
*/
public class LogConfiguration {
/** The default 'disable logging' property value. */
public static final String DISABLE_LOGGING_DEFAULT = "false";
/** The 'log level' property key. */
public static final String LOGLEVEL = "org.jfree.base.LogLevel";
/** The default 'log level' property value. */
public static final String LOGLEVEL_DEFAULT = "Info";
/** The 'log target' property key. */
public static final String LOGTARGET = "org.jfree.base.LogTarget";
/** The default 'log target' property value. */
public static final String LOGTARGET_DEFAULT =
PrintStreamLogTarget.class.getName();
/** The 'disable logging' property key. */
public static final String DISABLE_LOGGING = "org.jfree.base.NoDefaultDebug";
/**
* Default constructor.
*/
private LogConfiguration() {
// nothing required.
}
/**
* Returns the current log target.
*
* @return the log target.
*/
public static String getLogTarget()
{
return BaseBoot.getInstance().getGlobalConfig().getConfigProperty
(LOGTARGET, LOGTARGET_DEFAULT);
}
/**
* Sets the log target.
*
* @param logTarget the new log target.
*/
public static void setLogTarget(final String logTarget)
{
BaseBoot.getConfiguration().setConfigProperty (LOGTARGET, logTarget);
}
/**
* Returns the log level.
*
* @return the log level.
*/
public static String getLogLevel()
{
return BaseBoot.getInstance().getGlobalConfig().getConfigProperty
(LOGLEVEL, LOGLEVEL_DEFAULT);
}
/**
* Sets the log level, which is read from the global report configuration at
* the point that the classloader loads the {@link org.jfree.util.Log} class.
*
* Valid log levels are:
*
*
* "Error"
- error messages;
* "Warn"
- warning messages;
* "Info"
- information messages;
* "Debug"
- debug messages;
*
*
* Notes:
*
* - the setting is not case sensitive.
* - changing the log level after the {@link org.jfree.util.Log} class has been
* loaded will have no effect.
* - to turn of logging altogether, use the {@link #setDisableLogging} method.
*
*
* @param level the new log level.
*/
public static void setLogLevel(final String level)
{
BaseBoot.getConfiguration().setConfigProperty(LOGLEVEL, level);
}
/**
* Returns true
if logging is disabled, and false
otherwise.
*
* @return true, if logging is completly disabled, false otherwise.
*/
public static boolean isDisableLogging()
{
return BaseBoot.getInstance().getGlobalConfig().getConfigProperty
(DISABLE_LOGGING, DISABLE_LOGGING_DEFAULT).equalsIgnoreCase("true");
}
/**
* Sets the flag that disables logging.
*
* To switch off logging globally, you can use the following code:
*
* ReportConfiguration.getGlobalConfig().setDisableLogging(true);
*
* @param disableLogging the flag.
*/
public static void setDisableLogging(final boolean disableLogging)
{
BaseBoot.getConfiguration().setConfigProperty
(DISABLE_LOGGING, String.valueOf(disableLogging));
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy