Java Code Examples for java.util.logging.LogRecord#getParameters()
The following examples show how to use
java.util.logging.LogRecord#getParameters() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleFileOwnerQueryImplementationTest.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void publish(LogRecord record) { Runnable r = null; synchronized (this) { String message = record.getMessage(); if (message != null) { final Object[] params = record.getParameters(); if (params != null && params.length > 0) { message = MessageFormat.format(message, params); } if (message.equals(expected.peek())) { if (VERBOSE) { System.out.println(message); } expected.remove(); } r = actions.get(message); } } if (r != null) { r.run(); } }
Example 2
Source File: Installer.java From netbeans with Apache License 2.0 | 6 votes |
private static File getHeapDump(List<LogRecord> recs, boolean isAfterRestart) { LogRecord thrownLog = getThrownLog(recs); if (isAfterRestart) { Object[] parameters = thrownLog.getParameters(); if (parameters != null && parameters.length > 0) { String heapDumpPath = (String) parameters[parameters.length - 1]; File hdf = new File(heapDumpPath); if (!hdf.exists()) { heapDumpPath += ".old"; hdf = new File(heapDumpPath); } return hdf; } } return getHeapDump(); }
Example 3
Source File: JsParsingPerformanceTest.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void publish(LogRecord record) { String message = record.getMessage(); if (message != null && message.startsWith(MSG_PARSING_ALL)) { message = ((String)record.getParameters()[1]); if (message.contains("real2k")) { JsParsingPerformanceTest.parsingReal2k += getLongFromLogRecord(record); } else if (message.contains("real500")) { JsParsingPerformanceTest.parsingReal500 += getLongFromLogRecord(record); } else if (message.contains("syntheticDoc10k")) { JsParsingPerformanceTest.parsingSyntheticDoc10k += getLongFromLogRecord(record); } } else if (message != null && message.startsWith(MSG_PARSING_DOC)) { message = ((String)record.getParameters()[1]); if (message.contains("real2k")) { JsParsingPerformanceTest.parsingReal2kComment += getLongFromLogRecord(record); } else if (message.contains("real500")) { JsParsingPerformanceTest.parsingReal500Comment += getLongFromLogRecord(record); } else if (message.contains("syntheticDoc10k")) { JsParsingPerformanceTest.parsingSyntheticDoc10kComment += getLongFromLogRecord(record); } } }
Example 4
Source File: StartLog.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void publish(LogRecord rec) { Object[] args = rec.getParameters(); String msg = (args.length >= 1 && args[0] instanceof String) ? (String)args[0] : ""; // NOI18N long time = System.nanoTime()/1000000; if ("start".equals(rec.getMessage())) { // NOI18N start(msg, time); return; } if ("end".equals(rec.getMessage())) { // NOI18N end(msg, time); return; } if ("progress".equals(rec.getMessage())) { // NOI18N progress(msg, time); return; } }
Example 5
Source File: JulToLog4jHandler.java From scheduling with GNU Affero General Public License v3.0 | 6 votes |
private String toLog4jMessage(LogRecord record) { String message = record.getMessage(); // Format message try { Object parameters[] = record.getParameters(); if (parameters != null && parameters.length != 0) { // Check for the first few parameters ? if (message.contains("{0}") || message.contains("{1}") || message.contains("{2}") || message.contains("{3}")) { message = MessageFormat.format(message, parameters); } } } catch (Exception ex) { // ignore Exception } return message; }
Example 6
Source File: ChatLogFormatter.java From L2jBrasil with GNU General Public License v3.0 | 6 votes |
@Override public String format(LogRecord record) { Object[] params = record.getParameters(); StringBuilder output = new StringBuilder(); output.append('['); output.append(dateFmt.format(new Date(record.getMillis()))); output.append(']'); output.append(' '); if (params != null) { for (Object p : params) { output.append(p); output.append(' '); } } output.append(record.getMessage()); output.append(CRLF); return output.toString(); }
Example 7
Source File: CachingPreventsLoadingOfModuleManifestsTest.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void publish(LogRecord record) { if (Boolean.getBoolean("counting.off")) { return; } final String m = record.getMessage(); if (m != null && m.startsWith("Initialize data")) { Object[] params = record.getParameters(); assertNotNull("There are parameters", params); assertEquals("There is just one parameter: " + Arrays.toString(params), 1, params.length); if (params[0] == null) { // fixed modules are OK return; } if (isPlatformOrIde((File)params[0])) { return; } String prev = System.getProperty("manifestParsing"); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); if (prev != null) { pw.append(prev).append("\n"); } final String msg = m + ": " + params[0]; if (Boolean.getBoolean("no.stacks")) { pw.print(msg); } else { new Exception(msg).printStackTrace(pw); } pw.flush(); System.setProperty("manifestParsing", sw.toString()); } }
Example 8
Source File: LogfileHandler.java From cloudsync with GNU General Public License v2.0 | 5 votes |
@Override public void publish(LogRecord record) { if (record.getParameters() != null) return; super.publish(record); }
Example 9
Source File: Logging.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static void addParam(LogRecord record, Object param) { Object[] params = record.getParameters(); if(params == null) { params = new Object[]{ param }; } else { Object[] oldParams = params; params = new Object[oldParams.length + 1]; System.arraycopy(oldParams, 0, params, 0, oldParams.length); params[oldParams.length] = param; } record.setParameters(params); }
Example 10
Source File: TestLoggerBundleSync.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void publish(LogRecord record) { Object[] params = record.getParameters(); // Each GetRB thread has its own handler, but since they // log into the same logger, each handler may receive // messages emitted by other threads. // This means that GetRB#2.handler may receive a message // emitted by GetRB#1 at a time where the resource bundle // was still null. // To avoid falling into this trap, the GetRB thread passes // 'this' as argument to the messages it logs - which does // allow us here to ignore messages that where not emitted // by our own GetRB.this thread... if (params.length == 1) { if (params[0] == GetRB.this) { // The message was emitted by our thread. count++; rb = record.getResourceBundle(); rbName = record.getResourceBundleName(); } else { // The message was emitted by another thread: just // ignore it, as it may have been emitted at a time // where the resource bundle was still null, and // processing it may overwrite the 'rb' and 'rbName' // recorded from the message emitted by our own thread. if (VERBOSE) { System.out.println("Ignoring message logged by " + params[0]); } ignoreLogCount.incrementAndGet(); } } else { ignoreLogCount.incrementAndGet(); System.err.println("Unexpected message received"); } }
Example 11
Source File: UINode.java From netbeans with Apache License 2.0 | 5 votes |
static Node create(LogRecord r) { Children ch; if (r.getThrown() != null) { ch = new StackTraceChildren(r.getThrown()); } else if ("UI_ENABLED_MODULES".equals(r.getMessage()) || "UI_DISABLED_MODULES".equals(r.getMessage())) { ch = new ModulesChildren(r.getParameters()); } else { ch = Children.LEAF; } return new UINode(r, ch); }
Example 12
Source File: TestLogrbResourceBundle.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void publish(LogRecord record) { lastBundle = record.getResourceBundle(); lastBundleName = record.getResourceBundleName(); lastParams = record.getParameters(); lastThrown = record.getThrown(); lastMessage = record.getMessage(); }
Example 13
Source File: ItemLogFormatter.java From L2jBrasil with GNU General Public License v3.0 | 5 votes |
@Override public String format(LogRecord record) { StringBuilder output = new StringBuilder(); output.append('['); output.append(dateFmt.format(new Date(record.getMillis()))); output.append(']'); output.append(' '); output.append(record.getMessage()); for (Object p : record.getParameters()) { if (p == null) continue; output.append(','); output.append(' '); if (p instanceof L2ItemInstance) { L2ItemInstance item = (L2ItemInstance)p; output.append("item " + item.getObjectId() + ":"); if (item.getEnchantLevel() > 0) output.append("+" + item.getEnchantLevel() + " "); output.append(item.getItem().getName()); output.append("(" + item.getCount() + ")"); } //else if (p instanceof L2PcInstance) // output.append(((L2PcInstance)p).getName()); else output.append(p.toString()/* + ":" + ((L2Object)p).getObjectId()*/); } output.append(CRLF); return output.toString(); }
Example 14
Source File: TestLoggerBundleSync.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void publish(LogRecord record) { Object[] params = record.getParameters(); // Each GetRB thread has its own handler, but since they // log into the same logger, each handler may receive // messages emitted by other threads. // This means that GetRB#2.handler may receive a message // emitted by GetRB#1 at a time where the resource bundle // was still null. // To avoid falling into this trap, the GetRB thread passes // 'this' as argument to the messages it logs - which does // allow us here to ignore messages that where not emitted // by our own GetRB.this thread... if (params.length == 1) { if (params[0] == GetRB.this) { // The message was emitted by our thread. count++; rb = record.getResourceBundle(); rbName = record.getResourceBundleName(); } else { // The message was emitted by another thread: just // ignore it, as it may have been emitted at a time // where the resource bundle was still null, and // processing it may overwrite the 'rb' and 'rbName' // recorded from the message emitted by our own thread. if (VERBOSE) { System.out.println("Ignoring message logged by " + params[0]); } ignoreLogCount.incrementAndGet(); } } else { ignoreLogCount.incrementAndGet(); System.err.println("Unexpected message received"); } }
Example 15
Source File: TestLoggerBundleSync.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public synchronized void publish(LogRecord record) { Object[] params = record.getParameters(); // Each GetRB thread has its own handler, but since they // log into the same logger, each handler may receive // messages emitted by other threads. // This means that GetRB#2.handler may receive a message // emitted by GetRB#1 at a time where the resource bundle // was still null. // To avoid falling into this trap, the GetRB thread passes // 'this' as argument to the messages it logs - which does // allow us here to ignore messages that where not emitted // by our own GetRB.this thread... if (params.length == 1) { if (params[0] == GetRB.this) { // The message was emitted by our thread. count++; rb = record.getResourceBundle(); rbName = record.getResourceBundleName(); } else { // The message was emitted by another thread: just // ignore it, as it may have been emitted at a time // where the resource bundle was still null, and // processing it may overwrite the 'rb' and 'rbName' // recorded from the message emitted by our own thread. if (VERBOSE) { System.out.println("Ignoring message logged by " + params[0]); } ignoreLogCount.incrementAndGet(); } } else { ignoreLogCount.incrementAndGet(); System.err.println("Unexpected message received"); } }
Example 16
Source File: TestLogrbResourceBundle.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override public void publish(LogRecord record) { lastBundle = record.getResourceBundle(); lastBundleName = record.getResourceBundleName(); lastParams = record.getParameters(); lastThrown = record.getThrown(); lastMessage = record.getMessage(); }
Example 17
Source File: Log.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void publish(LogRecord record) { Object[] param = record.getParameters(); if (param == null) { return; } if (msg != null && !msg.equals(record.getMessage())) { return; } cnt++; for (Object o : param) { instances.put(o, record.getMessage()); } }
Example 18
Source File: TestLogrbResourceBundle.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public void publish(LogRecord record) { lastBundle = record.getResourceBundle(); lastBundleName = record.getResourceBundleName(); lastParams = record.getParameters(); lastThrown = record.getThrown(); lastMessage = record.getMessage(); }
Example 19
Source File: LogFormatter.java From netbeans with Apache License 2.0 | 4 votes |
/** * Format the given message to XML. * @param record the log record to be formatted. * @return a formatted log record */ public @Override String format(LogRecord record) { StringBuffer sb = new StringBuffer(1000); sb.append("<record>\n");// NOI18N sb.append(" <date>");// NOI18N appendISO8601(sb, record.getMillis()); sb.append("</date>\n");// NOI18N sb.append(" <millis>");// NOI18N sb.append(record.getMillis()); sb.append("</millis>\n");// NOI18N sb.append(" <sequence>");// NOI18N sb.append(record.getSequenceNumber()); sb.append("</sequence>\n");// NOI18N String name = record.getLoggerName(); if (name != null) { sb.append(" <logger>");// NOI18N escape(sb, name); sb.append("</logger>\n");// NOI18N } sb.append(" <level>");// NOI18N String level = Integer.toString(record.getLevel().intValue()); escape(sb, level); sb.append("</level>\n");// NOI18N if (record.getSourceClassName() != null) { sb.append(" <class>");// NOI18N escape(sb, record.getSourceClassName()); sb.append("</class>\n");// NOI18N } if (record.getSourceMethodName() != null) { sb.append(" <method>");// NOI18N escape(sb, record.getSourceMethodName()); sb.append("</method>\n");// NOI18N } sb.append(" <thread>");// NOI18N sb.append(record.getThreadID()); sb.append("</thread>\n");// NOI18N String message = record.getMessage(); if (message != null) { sb.append(" <message>");// NOI18N escape(sb, message); sb.append("</message>\n");// NOI18N } // If the message is being localized, output the key, resource // bundle name, and params. ResourceBundle bundle = record.getResourceBundle(); try { if (bundle != null && bundle.getString(message) != null) { sb.append(" <key>");// NOI18N escape(sb, message); sb.append("</key>\n");// NOI18N sb.append(" <catalog>");// NOI18N escape(sb, record.getResourceBundleName()); sb.append("</catalog>\n");// NOI18N } } catch (Exception exc) { // The message is not in the catalog. Drop through. Logger.getLogger(LogFormatter.class.getName()).log(Level.FINE, "Catalog loading error", exc);// NOI18N } Object parameters[] = record.getParameters(); // Check to see if the parameter was not a messagetext format // or was not null or empty if ( parameters != null && parameters.length != 0 && (message == null || message.indexOf("{") == -1) ) { for (int i = 0; i < parameters.length; i++) { sb.append(" <param>");// NOI18N try { escape(sb, paramToString(parameters[i])); } catch (Exception ex) { sb.append("???");// NOI18N } sb.append("</param>\n");// NOI18N } } if (record.getThrown() != null) { printThrown(record.getThrown(), sb); } sb.append("</record>\n");// NOI18N return sb.toString(); }
Example 20
Source File: Log.java From netbeans with Apache License 2.0 | 4 votes |
private Logger getPackageLogger() { if (logger == null) { String prop = System.getProperty(packageName, DEFAULT_NAME); for (int i = 1; i < LEVELS.length; i++) { if (prop.toLowerCase().equals(LEVEL_NAMES[i].toLowerCase())) { level = LEVELS[i]; break; } } LogManager.getLogManager().addLogger(new Logger(packageName, null) {}); logger = LogManager.getLogManager().getLogger(packageName); if (logger == null) { System.out.println(packageName + ": " + rb.getString("CANT_GET_LOGGER")); return Logger.getLogger("global"); } try { logger.setLevel(level); Handler handler = new ConsoleHandler(); handler.setLevel(level); // Default handlers don't provide class name or method name, so roll our own logger.setUseParentHandlers(false); Formatter formatter = new Formatter() { public String format(LogRecord record) { StringBuffer s = new StringBuffer(); s.append(record.getLevel().getLocalizedName()); s.append(' '); if (record.getLoggerName() != null) { s.append('['); s.append(record.getLoggerName()); s.append("]: "); } if (record.getSourceClassName() != null) { s.append("| "); if (record.getLevel().equals(Level.FINEST)) { String className = record.getSourceClassName(); s.append(className.substring(Math.max(className.lastIndexOf('.')+1,0))); } else { s.append(record.getSourceClassName()); } s.append(' '); } if (record.getSourceMethodName() != null) { s.append("| "); s.append(record.getSourceMethodName()); s.append("( "); Object[] parms = record.getParameters(); if (parms != null) { for (int i = 0; i < parms.length; i++) { if (i != 0) { s.append(", "); } s.append(parms[i]); } } s.append(" ) "); } if (record.getThrown() != null) { s.append("| "); s.append(record.getThrown()); } if (record.getMessage() != null) { s.append('|'); s.append(record.getMessage()); } s.append('\n'); return s.toString(); } }; handler.setFormatter(formatter); logger.addHandler(handler); } catch (SecurityException e) { } } return logger; }