List of usage examples for org.apache.commons.logging Log isFatalEnabled
boolean isFatalEnabled();
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * @param log the log where the messages will go * @param basename the base name of the resource bundle * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//* w w w .j a va 2 s. c o m*/ public static Msg fatal(Log log, BundleBaseName basename, String key, Object... varargs) { if (log.isFatalEnabled()) { Msg msg = Msg.createMsg(basename, key, varargs); log.fatal((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned *//*from w ww.j a va 2 s . c o m*/ public static Msg fatal(Log log, Throwable throwable, Locale locale, String key, Object... varargs) { if (log.isFatalEnabled()) { Msg msg = Msg.createMsg(locale, key, varargs); logFatalWithThrowable(log, key, msg, throwable); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * @param log the log where the messages will go * @param basename the base name of the resource bundle * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned * * @see Msg#createMsg(com.sos.i18n.Msg.BundleBaseName, Locale, String, Object[]) *///from w w w. j av a2 s .co m public static Msg fatal(Log log, BundleBaseName basename, Locale locale, String key, Object... varargs) { if (log.isFatalEnabled()) { Msg msg = Msg.createMsg(basename, locale, key, varargs); log.fatal((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param basename the base name of the resource bundle * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned */// ww w. j a va 2s . co m public static Msg fatal(Log log, Throwable throwable, BundleBaseName basename, String key, Object... varargs) { if (log.isFatalEnabled()) { Msg msg = Msg.createMsg(basename, key, varargs); logFatalWithThrowable(log, key, msg, throwable); return msg; } return null; }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the given message to the log at the fatal level. If the log level is not enabled, this method does * nothing and returns <code>null</code>. If a message was logged, its {@link Msg} will be returned. * * <p>The given Throwable will be passed to the logger so its stack can be dumped when appropriate.</p> * * @param log the log where the messages will go * @param throwable the throwable associated with the log message * @param basename the base name of the resource bundle * @param locale the locale to determine what bundle to use * @param key the resource bundle key name * @param varargs arguments to help fill in the resource bundle message * * @return if the message was logged, a non-<code>null</code> Msg object is returned * * @see Msg#createMsg(com.sos.i18n.Msg.BundleBaseName, Locale, String, Object[]) *//*from www.j a v a 2 s. com*/ public static Msg fatal(Log log, Throwable throwable, BundleBaseName basename, Locale locale, String key, Object... varargs) { if (log.isFatalEnabled()) { Msg msg = Msg.createMsg(basename, locale, key, varargs); logFatalWithThrowable(log, key, msg, throwable); return msg; } return null; }
From source file:net.sf.nmedit.nomad.core.NomadLoader.java
public Nomad createNomad(final NomadPlugin plugin) { NomadLoader.plugin = plugin;/*from ww w . j a v a2 s. c om*/ // first get the boot progress callbeck final SplashHandler progress = Boot.getSplashHandler(); // initializing ... progress.setText("Initializing Nomad..."); progress.setProgress(0.1f); // now we read all property files // 1. nomad.properties final Properties nProperties = new Properties(); getProperties(nProperties, Nomad.getCorePropertiesFile()); RootSystemProperties sproperties = new RootSystemProperties(nProperties); SystemPropertyFactory.sharedInstance().setFactory(new NomadPropertyFactory(sproperties)); // 1.2 init locale initLocale(); // 1.4 menu layout configuration InputStream mlIn = null; try { ClassLoader loader = getClass().getClassLoader(); mlIn = loader.getResourceAsStream("./MenuLayout.xml"); menuLayout = MenuLayout.getLayout(new BufferedInputStream(mlIn)); } catch (Exception e) { Log log = LogFactory.getLog(getClass()); if (log.isFatalEnabled()) { log.fatal("could not read MenuLayout", e); } throw new RuntimeException(e); } finally { try { if (mlIn != null) mlIn.close(); } catch (IOException e) { Log log = LogFactory.getLog(NomadLoader.class); if (log.isWarnEnabled()) { log.warn("closing menu layout", e); } } } // increase progress progress.setProgress(0.2f); // 1.5 initialize look and feel (important: before creating any swing components) String lafClassName = plugin.getDescriptor().getAttribute("javax.swing.LookAndFeel").getValue(); String themeClassName = plugin.getDescriptor().getAttribute("javax.swing.plaf.metal.MetalTheme").getValue(); String defaultLafOnPlatform = plugin.getDescriptor().getAttribute("nomad.plaf.usePlatformDefault") .getValue(); initLookAndFeel(lafClassName, themeClassName, defaultLafOnPlatform); // 1.6 initialize main window's menu progress.setProgress(0.3f); /* NomadActionControl nomadActions = new NomadActionControl( Nomad.sharedInstance() ); nomadActions.installActions(menuBuilder); */ progress.setProgress(0.5f); progress.setText("Initializing main window..."); activatePlugins(); progress.setText("Initializing services..."); JPFServiceInstallerTool.activateAllServices(plugin); progress.setText("Starting Nomad..."); // SwingUtilities.invokeLater(run); Nomad nomad = new Nomad(plugin, menuLayout); return nomad; }
From source file:com.amazon.carbonado.repo.tupl.LogEventListener.java
@Override public void notify(EventType type, String message, Object... args) { int intLevel = type.level.intValue(); Log log = mLog; if (log != null) { if (intLevel <= Level.INFO.intValue()) { if (type.category == EventType.Category.CHECKPOINT) { if (log.isDebugEnabled()) { log.debug(format(type, message, args)); }/*from w ww . jav a 2 s. c o m*/ } else if (log.isInfoEnabled()) { log.info(format(type, message, args)); } } else if (intLevel <= Level.WARNING.intValue()) { if (log.isWarnEnabled()) { log.warn(format(type, message, args)); } } else if (intLevel <= Level.SEVERE.intValue()) { if (log.isFatalEnabled()) { log.fatal(format(type, message, args)); } } } if (intLevel > Level.WARNING.intValue() && mPanicHandler != null) { mPanicHandler.onPanic(mDatabase, type, message, args); } }
From source file:com.siblinks.ws.common.BaseException.java
public void log(final Log log) { if (errorLevel.equals(ErrorLevel.INFO) && log.isDebugEnabled()) { log.debug("Info Message: ID - " + uniqueID + " User Message: " + userMessageKey); log.debug(StackTracer.getStackTrace(throwable)); } else if (errorLevel.equals(ErrorLevel.WARNING) && log.isWarnEnabled()) { log.warn("Warn Message: ID - " + uniqueID + " User Message: " + userMessageKey); log.warn(StackTracer.getStackTrace(throwable)); } else if (errorLevel.equals(ErrorLevel.ERROR) && log.isErrorEnabled()) { log.error("Error Message: ID - " + uniqueID + " User Message: " + userMessageKey); log.error(StackTracer.getStackTrace(throwable)); } else if (errorLevel.equals(ErrorLevel.FATAL) && log.isFatalEnabled()) { log.fatal("Fatal Message: ID - " + uniqueID + " User Message: " + userMessageKey); log.fatal(StackTracer.getStackTrace(throwable)); }//from w w w. j ava2s . c om logged = true; }
From source file:com.flexive.shared.exceptions.FxApplicationException.java
/** * Log a message at a given level (or error if no level given) * * @param log Log to use//from w w w.j a v a 2s . co m * @param message message to LOG * @param level log4j level to apply */ private void logMessage(Log log, String message, LogLevel level) { this.messageLogged = true; if (FxContext.get() != null && FxContext.get().isTestDivision()) return; //dont log exception traces during automated tests final Throwable cause = getCause() != null ? getCause() : this; if (level == null) log.error(message, cause); else { switch (level) { case DEBUG: if (log.isDebugEnabled()) log.debug(message); break; case ERROR: if (log.isErrorEnabled()) log.error(message, cause); break; case FATAL: if (log.isFatalEnabled()) log.fatal(message, cause); break; case INFO: if (log.isInfoEnabled()) log.info(message); break; // case Level.WARN_INT: default: if (log.isWarnEnabled()) log.warn(message); } } }
From source file:dk.statsbiblioteket.util.Logs.java
/** * Log the message and the elements to the log at the specified level. * Elements are converted to Strings and appended to the message. Arrays, * Lists and similar in the elements are expanded to a certain degree of * detail./* w w w . java 2s .co m*/ * * Sample input/output: * <code>log(myLog, Level.TRACE, false, "Started test", null, * 5, new String[]{"flim", "flam"});</code> * expands to * <code>log.trace("Started test (5, (flim, flam))");</code> * * @param log the log to log to. * @param level the level to log to (e.g. TRACE, DEBUG, INFO...). * @param verbose if true, the elements are expanded more than for false. * @param error the cause of this logging. If null, no cause is logged. * @param message the message for the log. * @param elements the elements to log. */ public static void log(Log log, Level level, String message, Throwable error, boolean verbose, Object... elements) { int maxLength = verbose ? VERBOSE_MAXLENGTH : DEFAULT_MAXLENGTH; int maxDepth = verbose ? VERBOSE_MAXDEPTH : DEFAULT_MAXDEPTH; String expanded = message; if (elements != null && elements.length > 0) { expanded += expand(elements, maxLength, maxDepth); } switch (level) { case TRACE: if (!log.isTraceEnabled()) { return; } if (error == null) { log.trace(expanded); } else { log.trace(expanded, error); } break; case DEBUG: if (!log.isDebugEnabled()) { return; } if (error == null) { log.debug(expanded); } else { log.debug(expanded, error); } break; case INFO: if (!log.isInfoEnabled()) { return; } if (error == null) { log.info(expanded); } else { log.info(expanded, error); } break; case WARN: if (!log.isWarnEnabled()) { return; } if (error == null) { log.warn(expanded); } else { log.warn(expanded, error); } break; case ERROR: if (!log.isErrorEnabled()) { return; } if (error == null) { log.error(expanded); } else { log.error(expanded, error); } break; case FATAL: if (!log.isFatalEnabled()) { return; } if (error == null) { log.fatal(expanded); } else { log.fatal(expanded, error); } break; default: throw new IllegalArgumentException("The level '" + level + "' is unknown"); } }