List of usage examples for java.util.logging LogRecord getMessage
public String getMessage()
From source file:org.ebayopensource.turmeric.eclipse.core.logging.PluginLogDelegateHandler.java
@Override public void publish(final LogRecord record) { if (record == null || StringUtils.isBlank(record.getMessage())) return;/*from w ww.j a v a 2s .c om*/ final int level = level(record.getLevel()); if (shouldLogRawMessage(record)) { log(level, record.getLoggerName(), record.getMessage(), null); } else { log(level, record.getLoggerName(), StringUtils.replace(formatter.format(record), "\n", "\n "), record.getThrown()); } }
From source file:joachimeichborn.geotag.logging.LongLogFormat.java
@Override public String format(final LogRecord aRecord) { final StringBuilder sb = new StringBuilder(); sb.append(new DateTime(aRecord.getMillis()).toString()); sb.append(" [").append(aRecord.getLevel().getName().charAt(0)).append("] "); sb.append(aRecord.getMessage()); sb.append(" <").append(aRecord.getLoggerName()).append(">"); sb.append(System.lineSeparator()); if (aRecord.getThrown() != null) { sb.append(ExceptionUtils.getStackTrace(aRecord.getThrown())); }/*from w w w . j a v a 2 s.c o m*/ return sb.toString(); }
From source file:net.poemerchant.ui.ScraperSwingWorker.java
@Override public Void doInBackground() throws Exception { // all logger message will also go to our printStream logger.addHandler(new StreamHandler(printStream, new Formatter() { @Override//from w w w. j a v a 2s. c om public String format(LogRecord record) { // System.out.println("intercept: " + record.getMessage()); return record.getMessage() + System.lineSeparator(); } }) { @Override public synchronized void publish(LogRecord record) { super.publish(record); flush(); } }); ShopIndexScraper scraper = new ShopIndexScraper(shopSubForumUrl); logger.info("Scrapping shops subform index: " + shopSubForumUrl); List<String> shopUrls = null; try { shopUrls = scraper.scrape(); } catch (PoEMerchantException e) { logger.severe("Error: " + e.getMessage() + ". Try again."); return null; } // shopUrls = new ArrayList(); // shopUrls.add(this.getClass().getResource("/1148541.htm").getFile()); logger.info("Sucessfully scraped subform, number of shops: " + shopUrls.size()); for (String url : shopUrls) { logger.info("Scrapping shop: " + url); try { scrapeAndSaveShop(configuration.getIndex(), configuration.getType(), url); } catch (Exception e) { logger.severe("error caught for " + url + ". err msg: " + e.getMessage()); } } logger.info(String.format("Sucessfully scraped %d shops.", shopUrls.size())); return null; }
From source file:ductive.log.JDKToCommonsHandler.java
@Override public void publish(LogRecord record) { String name = record.getLoggerName(); Log log = logs.get(name);/*from w w w . jav a 2s. c o m*/ if (log == null) logs.put(name, log = LogFactory.getLog(name)); String message = record.getMessage(); Throwable ex = record.getThrown(); Level level = record.getLevel(); if (Level.SEVERE == level) log.error(message, ex); else if (Level.WARNING == level) log.warn(message, ex); else if (Level.INFO == level) log.info(message, ex); else if (Level.CONFIG == level) log.debug(message, ex); else log.trace(message, ex); }
From source file:ffx.ui.LogHandler.java
/** * {@inheritDoc}/*from ww w. j a va2 s. c om*/ * * Publish a LogRecord. * * @since 1.0. */ @Override public synchronized void publish(LogRecord record) { if (record.getLevel() == Level.OFF) { if (record.getMessage().toLowerCase().contains("algorithm failure:")) { mainPanel.setExitType(MainPanel.ExitStatus.ALGORITHM_FAILURE); } return; } /** * Check if the record is loggable and that we have not already * encountered a fatal error. */ if (!isLoggable(record) || fatal) { return; } String msg; try { msg = getFormatter().format(record); } catch (Exception e) { /** * We don't want to throw an exception here, but we report the * exception to any registered ErrorManager. */ reportError(null, e, ErrorManager.FORMAT_FAILURE); return; } try { if (record.getLevel() == Level.SEVERE) { fatal = true; System.err.println(msg); Throwable throwable = record.getThrown(); if (throwable != null) { System.err.println(String.format(" Exception %s logged.", throwable)); } // If tryCatchSevere, and the throwable (if it exists) is not an Error, then... if (tryCatchSevere && (throwable == null || !(throwable instanceof Error))) { System.err.println(" Force Field X may not continue."); System.err.println(" Throwing new error..."); fatal = false; if (throwable != null) { throw new LoggerSevereError(throwable); } else { throw new LoggerSevereError(" Unknown exception"); } } System.err.println(" Force Field X will not continue."); System.err.println(" Shutting down..."); flush(); mainPanel.setExitType(MainPanel.ExitStatus.SEVERE); mainPanel.exit(); } ModelingShell shell = null; if (mainPanel != null) { shell = mainPanel.getModelingShell(); } if (!headless && shell != null) { shell.appendOutputNl(msg, shell.getResultStyle()); } else { System.out.println(msg); } } catch (Exception e) { /** * We don't want to throw an exception here, but we report the * exception to any registered ErrorManager. */ reportError(null, e, ErrorManager.WRITE_FAILURE); } }
From source file:org.energy_home.jemma.javagal.launcher.main.java
@Override public String format(LogRecord record) { className = record.getSourceClassName(); lastDotInClassName = className.lastIndexOf('.'); className = className.substring(lastDotInClassName + 1, className.length()); return "\n" + className + " " + record.getSourceMethodName() + ": " + record.getMessage(); }
From source file:com.tri_voltage.md.io.YoutubeVideoParser.java
@Override public String format(LogRecord arg0) { return arg0.getMessage() + newline; }
From source file:pcgen.persistence.lst.DataLoadTest.java
/** * Test the load of the current source.//from ww w. jav a2s. c o m * This will check for any load errors or warnings but ignores deprecation warnings. */ @Test public void testLoadSources() { UIDelegate uiDelegate = new MockUIDelegate(); SourceFileLoader loader = new SourceFileLoader(sourceSelection, uiDelegate); errors = new ArrayList<>(); loader.addPCGenTaskListener(this); loader.execute(); GameMode selectedGame = SystemCollections.getGameModeNamed(sourceSelection.getGameMode().get().getName()); selectedGame.clearLoadContext(); loader = null; List<String> errorList = new ArrayList<>(); List<String> warningList = new ArrayList<>(); for (LogRecord logRecord : errors) { if (logRecord.getLevel().intValue() > Logging.WARNING.intValue()) { errorList.add(logRecord.getMessage()); } else if (logRecord.getLevel().intValue() > Logging.INFO.intValue()) { warningList.add(logRecord.getMessage()); } } assertEquals("Errors encountered while loading " + sourceSelection, "", StringUtils.join(errorList, ",\n")); assertEquals("Warnings encountered while loading " + sourceSelection, "", StringUtils.join(errorList, ",\n")); }
From source file:org.ebayopensource.turmeric.runtime.tests.common.jetty.SimpleConsoleHandler.java
@Override public void publish(LogRecord record) { StringBuilder buf = new StringBuilder(); buf.append("[").append(record.getLevel().getName()); buf.append("] ").append(record.getLoggerName()); buf.append(" (").append(record.getSourceMethodName()); buf.append("): ").append(record.getMessage()); System.out.println(buf.toString()); if (record.getThrown() != null) { record.getThrown().printStackTrace(System.out); }/*w w w. j a v a 2s .c o m*/ }
From source file:com.l2jfree.util.logging.L2RuntimeLogFormatter.java
protected final void appendThrown(LogRecord record, TextBuilder tb) { Throwable throwable = record.getThrown(); if (throwable == null) { if (record.getLevel().intValue() >= L2AutoInitialization.EXTENDED_LOG_LEVEL.intValue()) throwable = new ExtendedLog(); else if (record.getMessage() != null && record.getMessage().contains("Unevenly distributed hash code - Degraded Preformance")) throwable = new ExtendedLog(); }/*from www . ja v a2s. co m*/ if (throwable != null) { StringWriter sw = null; PrintWriter pw = null; try { sw = new StringWriter(); pw = new PrintWriter(sw); throwable.printStackTrace(pw); appendNewline(tb); tb.append(sw); } finally { IOUtils.closeQuietly(pw); IOUtils.closeQuietly(sw); } } }