Java Code Examples for java.util.logging.LogRecord#setParameters()
The following examples show how to use
java.util.logging.LogRecord#setParameters() .
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: ManagedChannelOrphanWrapper.java From grpc-java with Apache License 2.0 | 6 votes |
@VisibleForTesting static int cleanQueue(ReferenceQueue<ManagedChannelOrphanWrapper> refqueue) { ManagedChannelReference ref; int orphanedChannels = 0; while ((ref = (ManagedChannelReference) refqueue.poll()) != null) { RuntimeException maybeAllocationSite = ref.allocationSite.get(); ref.clearInternal(); // technically the reference is gone already. if (!ref.shutdown.get()) { orphanedChannels++; Level level = Level.SEVERE; if (logger.isLoggable(level)) { String fmt = "*~*~*~ Channel {0} was not shutdown properly!!! ~*~*~*" + System.getProperty("line.separator") + " Make sure to call shutdown()/shutdownNow() and wait " + "until awaitTermination() returns true."; LogRecord lr = new LogRecord(level, fmt); lr.setLoggerName(logger.getName()); lr.setParameters(new Object[] {ref.channelStr}); lr.setThrown(maybeAllocationSite); logger.log(lr); } } } return orphanedChannels; }
Example 2
Source File: VespaFormatterTestCase.java From vespa with Apache License 2.0 | 6 votes |
/** * test that {0} etc is replaced properly */ @Test public void testTextFormatting () { VespaFormatter formatter = new VespaFormatter(serviceName, app); LogRecord testRecord = new LogRecord(Level.INFO, "this {1} is {0} test"); testRecord.setInstant(Instant.ofEpochMilli(1098709021843L)); testRecord.setThreadID(123); testRecord.setLoggerName("org.foo"); Object[] params = { "a small", "message" }; testRecord.setParameters(params); String expected = "1098709021.843000\t" + hostname + "\t" + pid + "/123" + "\t" + "serviceName\t" + app + ".org.foo\t" + "info\t" + "this message is a small test\n"; assertEquals(expected, formatter.format(testRecord)); }
Example 3
Source File: SerializeLogRecord.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static void generate() { try { LogRecord record = new LogRecord(Level.INFO, "Java Version: {0}"); record.setLoggerName("test"); record.setParameters(new Object[] {System.getProperty("java.version")}); System.out.println(generate(record)); } catch (IOException | ClassNotFoundException x) { throw new RuntimeException(x); } }
Example 4
Source File: MenuWarmUpTask.java From netbeans with Apache License 2.0 | 5 votes |
@Override public boolean cancel() { synchronized(rp) { if (task != null) { task.cancel(); } if (goOn != null) { goOn.set(false); LOG.log(Level.FINE, "Signaling cancel to {0}", System.identityHashCode(goOn)); } else { LOG.log(Level.FINE, "Cannot signal cancel, goOn is null"); } } ++counter; if (UILOG.isLoggable(Level.FINE)) { LogRecord r = new LogRecord(Level.FINE, "LOG_WINDOW_REFRESH_CANCEL"); // NOI18N r.setParameters(new Object[]{counter}); r.setResourceBundleName("org.netbeans.core.ui.warmup.Bundle"); // NOI18N r.setResourceBundle(NbBundle.getBundle(MenuWarmUpTask.class)); // NOI18N r.setLoggerName(UILOG.getName()); UILOG.log(r); } return true; }
Example 5
Source File: OJETUtils.java From netbeans with Apache License 2.0 | 5 votes |
public static void logUsage(List<? extends Object> params) { if (!isLogged.get()) { LogRecord logRecord = new LogRecord(Level.WARNING, USG_MESSAGE); logRecord.setLoggerName(USG_LOGGER.getName()); logRecord.setResourceBundle(NbBundle.getBundle(OJETUtils.class)); logRecord.setResourceBundleName(OJETUtils.class.getPackage().getName() + ".Bundle"); // NOI18N if (params != null) { logRecord.setParameters(params.toArray(new Object[params.size()])); } USG_LOGGER.log(logRecord); isLogged.set(true); } }
Example 6
Source File: Actions.java From netbeans with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent ev) { LogRecord rec = new LogRecord(Level.FINER, "UI_ACTION_BUTTON_PRESS"); // NOI18N rec.setParameters(new Object[] { button, button.getClass().getName(), action, action.getClass().getName(), action.getValue(Action.NAME) }); rec.setResourceBundle(NbBundle.getBundle(Actions.class)); rec.setResourceBundleName(Actions.class.getPackage().getName() + ".Bundle"); // NOI18N rec.setLoggerName(UILOG.getName()); UILOG.log(rec); }
Example 7
Source File: AbstractDelegatingLogger.java From openwebbeans-meecrowave with Apache License 2.0 | 5 votes |
public void logrb(Level level, String sourceClass, String sourceMethod, String bundleName, String msg, Object param1) { if (isLoggable(level)) { LogRecord lr = new LogRecord(level, msg); lr.setSourceClassName(sourceClass); lr.setSourceMethodName(sourceMethod); Object params[] = {param1 }; lr.setParameters(params); doLog(lr, bundleName); } }
Example 8
Source File: AbstractDelegatingLogger.java From tomee with Apache License 2.0 | 5 votes |
public void log(final Level level, final String msg, final Object[] params) { if (isLoggable(level)) { final LogRecord lr = new LogRecord(level, msg); lr.setParameters(params); doLog(lr); } }
Example 9
Source File: LogWrapperBase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
protected void doLog( Level level, String key, Object[] params, Class wrapperClass, Throwable thr ) { LogRecord lrec = new LogRecord( level, key ) ; if (params != null) lrec.setParameters( params ) ; inferCaller( wrapperClass, lrec ) ; lrec.setThrown( thr ) ; lrec.setLoggerName( loggerName ); lrec.setResourceBundle( logger.getResourceBundle() ) ; logger.log( lrec ) ; }
Example 10
Source File: Utils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Logs a vcs client action usage. * * @param vcs - the particular vcs "SVN", "CVS", "CC", "HG", ... */ public static void logVCSActionEvent(String vcs) { String key = "USG_VCS_ACTION" + vcs; if (checkMetricsKey(key)) return; LogRecord rec = new LogRecord(Level.INFO, "USG_VCS_ACTION"); rec.setParameters(new Object[] { vcs }); rec.setLoggerName(METRICS_LOG.getName()); METRICS_LOG.log(rec); }
Example 11
Source File: Logo.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void mouseClicked(MouseEvent e) { LogRecord rec = new LogRecord(Level.INFO, "USG_START_PAGE_LINK"); //NOI18N rec.setParameters(new Object[] {url} ); rec.setLoggerName(Constants.USAGE_LOGGER.getName()); rec.setResourceBundle(NbBundle.getBundle(BundleSupport.BUNDLE_NAME)); rec.setResourceBundleName(BundleSupport.BUNDLE_NAME); Constants.USAGE_LOGGER.log(rec); Utils.showURL( url ); }
Example 12
Source File: ProjectOpTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testProjectOpError() throws Exception { LogRecord rec = new LogRecord(Level.WARNING, "UI_CLOSED_PROJECTS"); rec.setParameters(new Object[] { "kuk", "buch", "org.netbeans.modules.xml.schema.model/1" }); ProjectOp op = ProjectOp.valueOf(rec); assertNull("Not recognized log", op); }
Example 13
Source File: LogAdapter.java From java-technology-stack with MIT License | 5 votes |
@SuppressWarnings("deprecation") // setMillis is deprecated in JDK 9 protected Object writeReplace() { LogRecord serialized = new LogRecord(getLevel(), getMessage()); serialized.setLoggerName(getLoggerName()); serialized.setResourceBundle(getResourceBundle()); serialized.setResourceBundleName(getResourceBundleName()); serialized.setSourceClassName(getSourceClassName()); serialized.setSourceMethodName(getSourceMethodName()); serialized.setSequenceNumber(getSequenceNumber()); serialized.setParameters(getParameters()); serialized.setThreadID(getThreadID()); serialized.setMillis(getMillis()); serialized.setThrown(getThrown()); return serialized; }
Example 14
Source File: FeatureManager.java From netbeans with Apache License 2.0 | 5 votes |
static void logUI(String msg, Object... params) { LogRecord rec = new LogRecord(Level.FINE, msg); rec.setResourceBundleName("org.netbeans.modules.ide.ergonomics.fod.Bundle"); // NOI18N rec.setResourceBundle(NbBundle.getBundle(ConfigurationPanel.class)); rec.setParameters(params); rec.setLoggerName(UILOG.getName()); UILOG.log(rec); }
Example 15
Source File: JSFUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Logs usage statistics data. * * @param srcClass source class * @param message USG message key * @param params message parameters, may be <code>null</code> */ public static void logUsage(Class srcClass, String message, Object[] params) { Parameters.notNull("message", message); // NOI18N LogRecord logRecord = new LogRecord(Level.INFO, message); logRecord.setLoggerName(USG_LOGGER.getName()); logRecord.setResourceBundle(NbBundle.getBundle(srcClass)); logRecord.setResourceBundleName(srcClass.getPackage().getName() + ".Bundle"); // NOI18N if (params != null) { logRecord.setParameters(params); } USG_LOGGER.log(logRecord); }
Example 16
Source File: PersistenceUtils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Logs feature usage. * * @param srcClass source class * @param message message key * @param params message parameters, may be <code>null</code> */ public static void logUsage(Class srcClass, String message, Object[] params) { Parameters.notNull("message", message); LogRecord logRecord = new LogRecord(Level.INFO, message); logRecord.setLoggerName(USG_LOGGER.getName()); logRecord.setResourceBundle(NbBundle.getBundle(srcClass)); logRecord.setResourceBundleName(srcClass.getPackage().getName() + ".Bundle"); // NOI18N if (params != null) { logRecord.setParameters(params); } USG_LOGGER.log(logRecord); }
Example 17
Source File: GestureSubmitter.java From netbeans with Apache License 2.0 | 5 votes |
static void logDebugStart(Session s, List<DebuggerEngine> engines) { LogRecord record = new LogRecord(Level.INFO, "USG_DEBUG_SESSION_START"); // NOI18N record.setResourceBundle(NbBundle.getBundle(GestureSubmitter.class)); record.setResourceBundleName(GestureSubmitter.class.getPackage().getName() + ".Bundle"); // NOI18N record.setLoggerName(USG_LOGGER.getName()); List params = new ArrayList(); params.add(s.getName()); params.add(s.getLocationName()); params.add(s.getCurrentLanguage()); record.setParameters(params.toArray(new Object[params.size()])); USG_LOGGER.log(record); }
Example 18
Source File: DatabaseUILogger.java From netbeans with Apache License 2.0 | 4 votes |
private static void log(String message, Object parameter) { LogRecord record = new LogRecord(Level.INFO, message); record.setParameters(new Object[] { parameter }); LOGGER.log(record); }
Example 19
Source File: JavaLoggerAdapter.java From unleash-maven-plugin with Eclipse Public License 1.0 | 4 votes |
@Override public void log(Level level, String msg, Object[] params) { LogRecord record = new LogRecord(level, msg); record.setParameters(params); log(record); }
Example 20
Source File: JmsTracing.java From brave with Apache License 2.0 | 3 votes |
/** * Avoids array allocation when logging a parameterized message when fine level is disabled. The * second parameter is optional. This is used to pinpoint provider-specific problems that throw * {@link JMSException} or {@link JMSRuntimeException}. * * <p>Ex. * <pre>{@code * try { * return message.getStringProperty(name); * } catch (Throwable t) { * Call.propagateIfFatal(e); * log(e, "error getting property {0} from message {1}", name, message); * return null; * } * }</pre> * * @param thrown the JMS exception that was caught * @param msg the format string * @param zero will end up as {@code {0}} in the format string * @param one if present, will end up as {@code {1}} in the format string */ static void log(Throwable thrown, String msg, Object zero, @Nullable Object one) { Logger logger = LoggerHolder.LOG; if (!logger.isLoggable(Level.FINE)) return; // fine level to not fill logs LogRecord lr = new LogRecord(Level.FINE, msg); Object[] params = one != null ? new Object[] {zero, one} : new Object[] {zero}; lr.setParameters(params); lr.setThrown(thrown); logger.log(lr); }