Java Code Examples for java.util.logging.LogRecord#setResourceBundleName()
The following examples show how to use
java.util.logging.LogRecord#setResourceBundleName() .
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: SingleModuleProperties.java From netbeans with Apache License 2.0 | 6 votes |
/** Sends info to UI handler about NetBeans APIs in use */ private static void logNetBeansAPIUsage(String msg, Collection<ModuleDependency> deps) { List<String> cnbs = new ArrayList<String>(); for (ModuleDependency moduleDependency : deps) { String cnb = moduleDependency.getModuleEntry().getCodeNameBase(); // observe just NetBeans API module usage if (cnb.startsWith("org.openide") || cnb.startsWith("org.netbeans")) { // NOI18N cnbs.add(cnb); } } if (cnbs.isEmpty()) { return; } LogRecord rec = new LogRecord(Level.CONFIG, msg); rec.setParameters(cnbs.toArray(new String[0])); rec.setResourceBundleName(SingleModuleProperties.class.getPackage().getName() + ".Bundle"); // NOI18N rec.setResourceBundle(NbBundle.getBundle(SingleModuleProperties.class)); rec.setLoggerName(UI_LOG.getName()); UI_LOG.log(rec); }
Example 2
Source File: ConnectPanel.java From netbeans with Apache License 2.0 | 6 votes |
private static void log(Connector c, Map<String, Argument> args) { LogRecord record = new LogRecord(Level.INFO, "USG_DEBUG_ATTACH_JPDA"); record.setResourceBundle(NbBundle.getBundle(ConnectPanel.class)); record.setResourceBundleName(ConnectPanel.class.getPackage().getName() + ".Bundle"); // NOI18N record.setLoggerName(USG_LOGGER.getName()); List<Object> params = new ArrayList<Object>(); params.add(c.name()); StringBuilder arguments = new StringBuilder(); for (Map.Entry argEntry : args.entrySet()) { //arguments.append(argEntry.getKey()); //arguments.append("="); arguments.append(argEntry.getValue()); arguments.append(", "); } if (arguments.length() > 2) { arguments.delete(arguments.length() - 2, arguments.length()); } params.add(arguments); record.setParameters(params.toArray(new Object[params.size()])); USG_LOGGER.log(record); }
Example 3
Source File: MenuWarmUpTask.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void windowDeactivated(WindowEvent e) { // proceed only if switching to external application if (e.getOppositeWindow() == null) { synchronized (rp) { if (task != null) { task.cancel(); } else { task = rp.create(this); } LOG.fine("Window deactivated, preparing refresh task"); } if (UILOG.isLoggable(Level.FINE)) { LogRecord r = new LogRecord(Level.FINE, "LOG_WINDOW_DEACTIVATED"); // NOI18N r.setResourceBundleName("org.netbeans.core.ui.warmup.Bundle"); // NOI18N r.setResourceBundle(NbBundle.getBundle(MenuWarmUpTask.class)); // NOI18N r.setLoggerName(UILOG.getName()); UILOG.log(r); } } }
Example 4
Source File: WelcomeOptions.java From netbeans with Apache License 2.0 | 6 votes |
public void setShowOnStartup( boolean show ) { boolean oldVal = isShowOnStartup(); if( oldVal == show ) { return; } prefs().putBoolean(PROP_SHOW_ON_STARTUP, show); if( null != propSupport ) propSupport.firePropertyChange( PROP_SHOW_ON_STARTUP, oldVal, show ); LogRecord rec = new LogRecord(Level.INFO, "USG_SHOW_START_PAGE"); //NOI18N rec.setParameters(new Object[] {show} ); rec.setLoggerName(Constants.USAGE_LOGGER.getName()); rec.setResourceBundle(NbBundle.getBundle(BundleSupport.BUNDLE_NAME)); rec.setResourceBundleName(BundleSupport.BUNDLE_NAME); Constants.USAGE_LOGGER.log(rec); }
Example 5
Source File: DecorableTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testIconOfTheNode() throws Exception { LogRecord r = new LogRecord(Level.INFO, "icon_msg"); r.setResourceBundleName("org.netbeans.lib.uihandler.TestBundle"); r.setResourceBundle(ResourceBundle.getBundle("org.netbeans.lib.uihandler.TestBundle")); r.setParameters(new Object[] { new Integer(1), "Ahoj" }); Node n = UINode.create(r); assertEquals("Name is taken from the message", "icon_msg", n.getName()); if (!n.getDisplayName().matches(".*Ahoj.*")) { fail("wrong display name, shall contain Ahoj: " + n.getDisplayName()); } Image img = n.getIcon(BeanInfo.ICON_COLOR_32x32); assertNotNull("Some icon", img); IconInfo imgReal = new IconInfo(img); IconInfo template = new IconInfo(getClass().getResource("testicon.png")); assertEquals("Icon from ICON_BASE used", template, imgReal); assertSerializedWell(r, n); }
Example 6
Source File: LogUtils.java From cxf with Apache License 2.0 | 6 votes |
private static void doLog(Logger log, Level level, String msg, Throwable t) { LogRecord record = new LogRecord(level, msg); record.setLoggerName(log.getName()); record.setResourceBundleName(log.getResourceBundleName()); record.setResourceBundle(log.getResourceBundle()); if (t != null) { record.setThrown(t); } //try to get the right class name/method name - just trace //back the stack till we get out of this class StackTraceElement[] stack = (new Throwable()).getStackTrace(); String cname = LogUtils.class.getName(); for (int x = 0; x < stack.length; x++) { StackTraceElement frame = stack[x]; if (!frame.getClassName().equals(cname)) { record.setSourceClassName(frame.getClassName()); record.setSourceMethodName(frame.getMethodName()); break; } } log.log(record); }
Example 7
Source File: LogContext.java From netbeans with Apache License 2.0 | 5 votes |
void log() { // prevent logging of events within 3 minutes from the start of scan. Do not freeze... if (canLogScanCancel()) { log(true, true); } else { if (System.getProperty(RepositoryUpdater.PROP_SAMPLING) == null) { // enable profiling just up to the 1st exception report System.setProperty(RepositoryUpdater.PROP_SAMPLING, "oneshot"); // NOI18N } final LogRecord r = new LogRecord(Level.INFO, LOG_MESSAGE_EARLY); r.setResourceBundle(NbBundle.getBundle(LogContext.class)); r.setResourceBundleName(LogContext.class.getPackage().getName() + ".Bundle"); //NOI18N r.setLoggerName(LOG.getName()); LOG.log(r); // schedule the log for later, after enough time elapses. RequestProcessor.getDefault().post(new Runnable() { @Override public void run() { synchronized (LogContext.this) { if (finished == 0) { log(true, true); } } } }, (int)EXEC_TRESHOLD); } }
Example 8
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 9
Source File: LinkButton.java From netbeans with Apache License 2.0 | 5 votes |
protected void logUsage() { LogRecord rec = new LogRecord(Level.INFO, "USG_START_PAGE_LINK"); //NOI18N String id = usageTrackingId; if( null == id ) id = getText(); rec.setParameters(new Object[] {id} ); rec.setLoggerName(Constants.USAGE_LOGGER.getName()); rec.setResourceBundle(NbBundle.getBundle(BundleSupport.BUNDLE_NAME)); rec.setResourceBundleName(BundleSupport.BUNDLE_NAME); Constants.USAGE_LOGGER.log(rec); System.err.println("usage: " + id); }
Example 10
Source File: LoggingUtils.java From netbeans with Apache License 2.0 | 5 votes |
private static void logUsingSourceClass(Logger logger, Class srcClass, String message, Object[] params) { LogRecord logRecord = createLogRecord(logger, message, params); logRecord.setResourceBundle(NbBundle.getBundle(srcClass)); if (srcClass != null && srcClass.getPackage() != null) { logRecord.setResourceBundleName(srcClass.getPackage().getName() + ".Bundle"); // NOI18N } logger.log(logRecord); }
Example 11
Source File: UINodeTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testDisplayNameOfTheNode() throws Exception { LogRecord r = new LogRecord(Level.INFO, "test_msg"); r.setResourceBundleName("org.netbeans.modules.uihandler.TestBundle"); r.setResourceBundle(ResourceBundle.getBundle("org.netbeans.modules.uihandler.TestBundle")); r.setParameters(new Object[] { new Integer(1), "Ahoj" }); Node n = UINode.create(r); assertEquals("Name is taken from the message", "test_msg", n.getName()); if (!n.getDisplayName().matches(".*Ahoj.*1.*")) { fail("wrong display name, shall contain Ahoj and 1: " + n.getDisplayName()); } assertSerializedWell(n); }
Example 12
Source File: GestureSubmitter.java From visualvm with GNU General Public License v2.0 | 5 votes |
private static void logUsage(String startType, List<Object> params) { LogRecord record = new LogRecord(Level.INFO, "USG_PROFILER_" + startType); // NOI18N record.setResourceBundle(NbBundle.getBundle(GestureSubmitter.class)); record.setResourceBundleName(GestureSubmitter.class.getPackage().getName() + ".Bundle"); // NOI18N record.setLoggerName(USG_LOGGER.getName()); record.setParameters(params.toArray(new Object[0])); USG_LOGGER.log(record); }
Example 13
Source File: AbstractDelegatingLogger.java From cxf with Apache License 2.0 | 5 votes |
protected void doLog(LogRecord lr) { lr.setLoggerName(getName()); String rbname = getResourceBundleName(); if (rbname != null) { lr.setResourceBundleName(rbname); lr.setResourceBundle(getResourceBundle()); } internalLog(lr); }
Example 14
Source File: DecorableTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testDisplayNameOfTheNode() throws Exception { LogRecord r = new LogRecord(Level.INFO, "test_msg"); r.setResourceBundleName("org.netbeans.lib.uihandler.TestBundle"); r.setResourceBundle(ResourceBundle.getBundle("org.netbeans.lib.uihandler.TestBundle")); r.setParameters(new Object[] { new Integer(1), "Ahoj" }); Node n = UINode.create(r); assertEquals("Name is taken from the message", "test_msg", n.getName()); if (!n.getDisplayName().matches(".*Ahoj.*1.*")) { fail("wrong display name, shall contain Ahoj and 1: " + n.getDisplayName()); } assertSerializedWell(r, n); }
Example 15
Source File: GestureSubmitter.java From netbeans with Apache License 2.0 | 5 votes |
private static void logUsage(String startType, List<Object> params) { LogRecord record = new LogRecord(Level.INFO, "USG_PROFILER_" + startType); // NOI18N record.setResourceBundle(NbBundle.getBundle(GestureSubmitter.class)); record.setResourceBundleName(GestureSubmitter.class.getPackage().getName() + ".Bundle"); // NOI18N record.setLoggerName(USG_LOGGER.getName()); record.setParameters(params.toArray(new Object[0])); USG_LOGGER.log(record); }
Example 16
Source File: LogUtils.java From netbeans with Apache License 2.0 | 5 votes |
private static void log(String message, Object[] params) { Parameters.notNull("params", params); // NOI18N LogRecord logRecord = new LogRecord(Level.INFO, message); logRecord.setLoggerName(USG_LOGGER_WEBSVC.getName()); logRecord.setResourceBundle(NbBundle.getBundle(LogUtils.class)); logRecord.setResourceBundleName(LogUtils.class.getPackage().getName() + ".Bundle"); // NOI18N if (params != null) { logRecord.setParameters(params); } USG_LOGGER_WEBSVC.log(logRecord); }
Example 17
Source File: Utils.java From netbeans with Apache License 2.0 | 5 votes |
/** * Logs vcs command usage. * * @param vcs - the particular vcs "GIT", "HG", ... * @param time - time in millis the command took to finish * @param modifications - number of modified/created/deleted files during * the command's progress * @param command - command name * @param external - true if the command was invoked externally * (e.g. on commandline) and not from within the IDE. */ public static void logVCSCommandUsageEvent (String vcs, long time, long modifications, String command, boolean external) { if (command == null) { command = "UNKNOWN"; //NOI18N } LogRecord rec = new LogRecord(Level.INFO, "USG_VCS_CMD"); //NOI18N String cmdType = external ? "EXTERNAL" : "INTERNAL"; rec.setResourceBundle(NbBundle.getBundle(Utils.class)); rec.setResourceBundleName(Utils.class.getPackage().getName() + ".Bundle"); //NOI18N rec.setParameters(new Object[] { vcs, time, modifications, command, cmdType }); rec.setLoggerName(UIGESTURES_LOG.getName()); UIGESTURES_LOG.log(rec); }
Example 18
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 19
Source File: LogRecords.java From netbeans with Apache License 2.0 | 4 votes |
public void endElement(String uri, String localName, String qName) throws SAXException { if (current != null) { String v = chars.toString(); values.put(current, v); if (current == Elem.PARAM) { if (params == null) { params = new ArrayList<String>(); } params.add(v); if (params.size() > 1500) { LOG.severe("Too long params when reading a record. Deleting few. Msg: " + Elem.MESSAGE.parse(values)); // NOI18N for (String p : params) { LOG.fine(p); } params.clear(); } } } current = null; chars = new StringBuilder(); if (currentEx != null && currentEx.values != null) { if ("frame".equals(qName)) { // NOI18N String line = Elem.LINE.parse(values); StackTraceElement elem = new StackTraceElement( Elem.CLASS.parse(values), Elem.METHOD.parse(values), Elem.FILE.parse(values), line == null ? -1 : Integer.parseInt(line) ); currentEx.trace.add(elem); values.remove(Elem.CLASS); values.remove(Elem.METHOD); values.remove(Elem.LINE); } if ("exception".equals(qName)) { currentEx.message = values.get(Elem.MESSAGE); String more = values.get(Elem.MORE); if (more != null) currentEx.more = Integer.parseInt(more); if (exceptions == null){ exceptions = new ArrayDeque<FakeException>(); } exceptions.add(currentEx); values = currentEx.values; currentEx = null; } return; } if ("record".equals(qName)) { // NOI18N String millis = Elem.MILLIS.parse(values); String seq = Elem.SEQUENCE.parse(values); String lev = Elem.LEVEL.parse(values); String thread = Elem.THREAD.parse(values); String msg = Elem.MESSAGE.parse(values); String key = Elem.KEY.parse(values); String catalog = Elem.CATALOG.parse(values); if (lev != null) { LogRecord r = new LogRecord(parseLevel(lev), key != null && catalog != null ? key : msg); try { r.setThreadID(parseInt(thread)); } catch (NumberFormatException ex) { LOG.log(Level.WARNING, ex.getMessage(), ex); } r.setSequenceNumber(parseLong(seq)); r.setMillis(parseLong(millis)); r.setResourceBundleName(key); if (catalog != null && key != null) { r.setResourceBundleName(catalog); if (!"<null>".equals(catalog)) { // NOI18N try { ResourceBundle b = NbBundle.getBundle(catalog); b.getObject(key); // ok, the key is there r.setResourceBundle(b); } catch (MissingResourceException e) { LOG.log(Level.CONFIG, "Cannot find resource bundle {0} for key {1}", new Object[] { catalog, key }); r.setResourceBundle(new FakeBundle(key, msg)); } } else { LOG.log(Level.CONFIG, "Cannot find resource bundle <null> for key {1}", key); } } if (params != null) { r.setParameters(params.toArray()); } if (exceptions != null) { r.setThrown(createThrown(null)); // exceptions = null; should be empty after poll } callback.publish(r); } currentEx = null; params = null; values.clear(); } }
Example 20
Source File: LogRecords.java From visualvm with GNU General Public License v2.0 | 4 votes |
public void endElement(String uri, String localName, String qName) throws SAXException { if (current != null) { String v = chars.toString(); values.put(current, v); if (current == Elem.PARAM) { if (params == null) { params = new ArrayList<String>(); } params.add(v); if (params.size() > 1500) { LOG.severe("Too long params when reading a record. Deleting few. Msg: " + Elem.MESSAGE.parse(values)); // NOI18N for (String p : params) { LOG.fine(p); } params.clear(); } } } current = null; chars = new StringBuilder(); if (currentEx != null && currentEx.values != null) { if ("frame".equals(qName)) { // NOI18N String line = Elem.LINE.parse(values); StackTraceElement elem = new StackTraceElement( Elem.CLASS.parse(values), Elem.METHOD.parse(values), Elem.FILE.parse(values), line == null ? -1 : Integer.parseInt(line) ); currentEx.trace.add(elem); values.remove(Elem.CLASS); values.remove(Elem.METHOD); values.remove(Elem.LINE); } if ("exception".equals(qName)) { currentEx.message = values.get(Elem.MESSAGE); String more = values.get(Elem.MORE); if (more != null) currentEx.more = Integer.parseInt(more); if (exceptions == null){ exceptions = new ArrayDeque<FakeException>(); } exceptions.add(currentEx); values = currentEx.values; currentEx = null; } return; } if ("record".equals(qName)) { // NOI18N String millis = Elem.MILLIS.parse(values); String seq = Elem.SEQUENCE.parse(values); String lev = Elem.LEVEL.parse(values); String thread = Elem.THREAD.parse(values); String msg = Elem.MESSAGE.parse(values); String key = Elem.KEY.parse(values); String catalog = Elem.CATALOG.parse(values); if (lev != null) { LogRecord r = new LogRecord(parseLevel(lev), key != null && catalog != null ? key : msg); try { r.setThreadID(parseInt(thread)); } catch (NumberFormatException ex) { LOG.log(Level.WARNING, ex.getMessage(), ex); } r.setSequenceNumber(parseLong(seq)); r.setMillis(parseLong(millis)); r.setResourceBundleName(key); if (catalog != null && key != null) { r.setResourceBundleName(catalog); if (!"<null>".equals(catalog)) { // NOI18N try { ResourceBundle b = NbBundle.getBundle(catalog); b.getObject(key); // ok, the key is there r.setResourceBundle(b); } catch (MissingResourceException e) { LOG.log(Level.CONFIG, "Cannot find resource bundle {0} for key {1}", new Object[] { catalog, key }); r.setResourceBundle(new FakeBundle(key, msg)); } } else { LOG.log(Level.CONFIG, "Cannot find resource bundle <null> for key {1}", key); } } if (params != null) { r.setParameters(params.toArray()); } if (exceptions != null) { r.setThrown(createThrown(null)); // exceptions = null; should be empty after poll } callback.publish(r); } currentEx = null; params = null; values.clear(); } }