List of usage examples for org.apache.commons.logging Log fatal
void fatal(Object 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./*from w w w . j ava 2 s. c o 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"); } }
From source file:com.acc.web.manager.LogManager.java
private void log(Object logTypeObject, Object prefixObject, Object informationObject, LogType logType) { if (!AppLibConstant.isUseLog()) { return;//from www . j a v a 2 s. co m } Log log = logType == LogType.SYSTEMOUT || logType == LogType.FILE ? null : this.getLogger(logTypeObject); String logString = this.getLogString(prefixObject, informationObject); switch (logType) { case SYSTEMOUT: super.systemOut(logString); break; case FILE: super.fileOut(logString); break; case INFO: log.info(logString); break; case WARN: log.warn(logString); break; case DEBUG: log.debug(logString); break; case ERROR: log.error(logString); break; case FATAL: log.fatal(logString); break; } }
From source file:org.acmsl.queryj.api.AbstractTemplate.java
/** * Prints a log message displaying ClassLoader issues related * to ANTLR.jar and StringTemplate.jar.//w w w . ja v a 2 s . c om */ protected static void traceANTLRClassLoadingIssues() { // CharScanner; panic: ClassNotFoundException: // org.antlr.stringtemplate.language.ChunkToken // can happen if ANTLR gets loaded by a ClassLoader // with no reference to StringTemplate classes. @Nullable final Log t_Log = UniqueLogFactory.getLog(AbstractQueryJTemplate.class); @NotNull final ClassLoaderUtils t_ClassLoaderUtils = ClassLoaderUtils.getInstance(); if (t_Log != null) { @NotNull final StringBuilder t_sbMessage = new StringBuilder(); @Nullable final String t_strAntlrLocation = t_ClassLoaderUtils.findLocation(ANTLRParser.class); @Nullable final String t_strStringTemplateLocation = t_ClassLoaderUtils.findLocation(ST.class); t_sbMessage.append("A fatal error in StringTemplate-based generation " + "has stopped QueryJ build process.\n" + "If you see error messages from StringTemplate, " + "review your templates. Otherwise, if the VM " + "exited due to ClassNotFoundException or " + "NoClassDefFoundException regarding ANTLR or StringTemplate " + "classes (i.e. ChunkToken), then " + "antlr-X.Y.jar has been loaded by a class loader " + "with no idea of where StringTemplate classes " + "are, and therefore ANTLR's reflection-based " + "instantiation fails. Check your classpath or the way " + "it's defined by Ant or any other tool you might be " + "using. "); final boolean t_bAntlrLocationFound = ((t_strAntlrLocation != null) && (t_strAntlrLocation.trim().length() > 0)); final boolean t_bStringTemplateLocationFound = ((t_strStringTemplateLocation != null) && (t_strStringTemplateLocation.trim().length() > 0)); if ((t_bAntlrLocationFound) || (t_bStringTemplateLocationFound)) { t_sbMessage.append("Hint: "); if ((t_strAntlrLocation != null) && (t_strAntlrLocation.trim().length() > 0)) { t_sbMessage.append("ANTLR is loaded from "); t_sbMessage.append(t_strAntlrLocation); } if (t_bStringTemplateLocationFound) { if (t_bAntlrLocationFound) { t_sbMessage.append(" whereas "); } t_sbMessage.append("StringTemplate is loaded from "); t_sbMessage.append(t_strStringTemplateLocation); } } t_Log.fatal(t_sbMessage.toString()); } }
From source file:org.acmsl.queryj.api.MetaLanguageUtils.java
/** * Retrieves whether the table is meant to be decorated. * @param tableComment the table comment. * @return such condition./*from ww w. j av a 2 s. co m*/ */ public boolean retrieveTableDecorator(@NotNull final String tableComment) { boolean result = false; if (!isEmpty(tableComment)) { try { @NotNull final PerCommentParser t_Parser = setUpParser(tableComment); @Nullable final ParseTree t_Tree = t_Parser.tableComment(); if (t_Tree != null) { @NotNull final PerCommentVisitor<Boolean> t_Visitor = new PerCommentTabDecoratorVisitor(); try { @Nullable final Boolean resultValue = t_Visitor.visit(t_Tree); if (resultValue != null) { result = resultValue; } } catch (@NotNull final Throwable npe) { @Nullable final Log t_Log = UniqueLogFactory.getLog(MetaLanguageUtils.class); if (t_Log != null) { t_Log.fatal(npe); } npe.printStackTrace(System.err); } } } catch (@NotNull final RecognitionException recognitionException) { @Nullable final Log t_Log = UniqueLogFactory.getLog(MetaLanguageUtils.class); if (t_Log != null) { t_Log.error(Literals.INVALID_TABLE_COMMENT + tableComment, recognitionException); } } } return result; }
From source file:org.acmsl.queryj.customsql.xml.SqlXmlParserImpl.java
/** * Processes given collection./* ww w. j a v a 2s . com*/ * @param collection the collection to process. */ @SuppressWarnings("unchecked") protected void processCollection(@NotNull final List<? extends IdentifiableElement<String>> collection) { for (@Nullable final IdentifiableElement<String> t_Item : collection) { if (t_Item instanceof Sql<?>) { addQuery((Sql<String>) t_Item); } else if (t_Item instanceof Result<?>) { addResult((Result<String>) t_Item); } else if (t_Item instanceof Property<?>) { addProperty((Property<String>) t_Item); } else if (t_Item instanceof PropertyRef) { addPropertyRef((PropertyRef) t_Item); } else if (t_Item instanceof Parameter<?, ?>) { addParameter((Parameter<String, ?>) t_Item); } else if (t_Item instanceof ParameterRef) { addParameterRef((ParameterRef) t_Item); } else if (t_Item instanceof ConnectionFlags) { addConnectionFlags((ConnectionFlags) t_Item); } else if (t_Item instanceof StatementFlags) { addStatementFlags((StatementFlags) t_Item); } else if (t_Item instanceof ResultSetFlags) { addResultSetFlags((ResultSetFlags) t_Item); } else { @Nullable final Log t_Log = UniqueLogFactory.getLog(SqlXmlParserImpl.class); if (t_Log != null) { t_Log.fatal("Unexpected element : " + t_Item); } } } }
From source file:org.acmsl.queryj.customsql.xml.SqlXmlParserImpl.java
/** * Adds a new result./*from w ww . j av a 2s . c om*/ * @param id the result id. * @param result the <code>Result</code> instance. * @param results the results. */ protected void addResult(@NotNull final String id, @NotNull final Result<String> result, @NotNull final List<Result<String>> results) { if (!results.contains(result)) { results.add(result); } else { @Nullable final Log t_Log = UniqueLogFactory.getLog(SqlXmlParserImpl.class); if (t_Log != null) { t_Log.fatal(id + " is defined more than once"); } } }
From source file:org.alfresco.extension.bulkimport.util.LogUtils.java
public final static void fatal(final Log log, final String message) { log.fatal(PREFIX + message); }
From source file:org.apache.hadoop.mapreduce.lib.input.RHadoopInputFormat.java
@SuppressWarnings("deprecation") public HashSet<InputSplit> chunkIndex(FileSystem fs, Path filenamePath) { HashSet<InputSplit> splitSet = new HashSet<InputSplit>(); try {//www . j av a 2s . com // reading FSDataInputStream in = fs.open(filenamePath); String line; Path file = null; long start = 0; long length = 0; Log LOG = LogFactory.getLog(FileInputFormat.class); line = in.readLine(); LOG.fatal("RHadoop : opened index file, first line = " + line); while (line != null) { String[] splits = line.split(" "); if (splits.length < 5) throw new Exception("Less Than 5 splits"); String lower = splits[0], upper = splits[1]; file = new Path(splits[2]); start = Long.parseLong(splits[3]); length = Long.parseLong(splits[4]); splits = line.split("\\["); if (splits.length != 2) throw new Exception("[ split not 2."); String hostStr = splits[1]; hostStr = hostStr.substring(0, hostStr.length() - 1); String[] hostSplits = hostStr.split(","); for (int i = 0; i < hostSplits.length; i++) hostSplits[i] = hostSplits[i].trim(); if (isValidKeyRange(lower, upper)) splitSet.add(new FileSplit(file, start, length, hostSplits)); line = in.readLine(); } in.close(); } catch (Exception e) { e.printStackTrace(); } return splitSet; }
From source file:org.apache.myfaces.util.DebugUtils.java
public static void assertFatal(boolean condition, Log log_, String msg) throws FacesException { if (!condition) { log_.fatal(msg); throw new FacesException(msg); }//from w ww . j a v a 2s . c om }
From source file:org.apache.tajo.engine.planner.physical.PhysicalExec.java
protected void fatal(Log log, String message) { log.fatal("[" + context.getTaskId() + "] " + message); }