Java 类java.util.logging.LogRecord 实例源码

项目:monarch    文件:LogWrapper.java   
private LogWrapper() {
  logger = Logger.getLogger(this.getClass().getCanonicalName());

  Cache cache = CliUtil.getCacheIfExists();
  if (cache != null && !cache.isClosed()) {
    // TODO - Abhishek how to set different log levels for different handlers???
    logger.addHandler(cache.getLogger().getHandler());
    CommandResponseWriterHandler handler = new CommandResponseWriterHandler();
    handler.setFilter(new Filter() {
      @Override
      public boolean isLoggable(LogRecord record) {
        return record.getLevel().intValue() >= Level.FINE.intValue();
      }
    });
    handler.setLevel(Level.FINE);
    logger.addHandler(handler);
  }
  logger.setUseParentHandlers(false);
}
项目:jboss-eap7.1-playground    文件:PlaygroundFormatter.java   
/**
 * Format the given LogRecord.
 * 
 * @param record
 *            the log record to be formatted.
 * @return a formatted log record
 */
@Override
public String format(LogRecord record) {

    StringBuilder sb = new StringBuilder();

    LocalDateTime time = Instant.ofEpochMilli(record.getMillis()).atZone(ZoneId.systemDefault()).toLocalDateTime();

    sb.append(TIME_FORMAT.format(time)).append(" [")
      .append(record.getLevel())
      .append("] ")
      .append(record.getSourceClassName())
      .append(".")
      .append(record.getSourceMethodName())
      .append("  ")
      .append(record.getMessage())
      .append("\n");

    return sb.toString();
}
项目:Pogamut3    文件:SimpleLogging.java   
public static void addConsoleLogging() {
    Logger log = Logger.getAnonymousLogger();
    while (log != null) {
        if (log.getParent() == null) {
            log.addHandler(new Handler() {

                @Override
                public void close() throws SecurityException {
                }

                @Override
                public void flush() {
                }

                @Override
                public void publish(LogRecord record) {
                    System.out.println("[" + record.getLevel() + "] " + record.getMessage());
                }

            });
        }
        log = log.getParent();
    }   
}
项目:L2jBrasil    文件:ChatLogFormatter.java   
@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();
}
项目:L2jBrasil    文件:FileLogFormatter.java   
@Override
public String format(LogRecord record)
{
       StringBuilder output = new StringBuilder();

    return output
    .append(dateFmt.format(new Date(record.getMillis())))
    .append(underscore)
    .append(record.getLevel().getName())
    .append(underscore)
    .append(record.getThreadID())
    .append(underscore)
    .append(record.getLoggerName())
    .append(underscore)
    .append(record.getMessage())
    .append(CRLF)
    .toString();
}
项目:XXXX    文件:Logger.java   
/**
 * Helper that configures java.util.logging to sanely log messages at FINE level without additional
 * formatting.
 */
public JavaLogger appendToFile(String logfile) {
  logger.setLevel(java.util.logging.Level.FINE);
  try {
    FileHandler handler = new FileHandler(logfile, true);
    handler.setFormatter(new SimpleFormatter() {
      @Override
      public String format(LogRecord record) {
        return String.format("%s%n", record.getMessage()); // NOPMD
      }
    });
    logger.addHandler(handler);
  } catch (IOException e) {
    throw new IllegalStateException("Could not add file handler.", e);
  }
  return this;
}
项目:L2jBrasil    文件:L2ItemInstance.java   
/**
 * Sets the quantity of the item.<BR><BR>
 * <U><I>Remark :</I></U> If loc and loc_data different from database, say datas not up-to-date
 * @param process : String Identifier of process triggering this action
 * @param count : int
 * @param creator : L2PcInstance Player requesting the item creation
 * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
 */
public void changeCount(String process, int count, L2PcInstance creator, L2Object reference)
{
       if (count == 0) return;
       if ( count > 0 && _count > Integer.MAX_VALUE - count) _count = Integer.MAX_VALUE;
       else _count += count;
       if (_count < 0) _count = 0;
       _storedInDb = false;

    if (Config.LOG_ITEMS)
    {
        LogRecord record = new LogRecord(Level.INFO, "CHANGE:" + process);
        record.setLoggerName("item");
        record.setParameters(new Object[]{this, creator, reference});
        _logItems.log(record);
    }
}
项目:MooProject    文件:ConciseFormatter.java   
@Override
@SuppressWarnings("ThrowableResultIgnored")
public String format(LogRecord record) {
    StringBuilder formatted = new StringBuilder();

    formatted.append("[");
    formatted.append(date.format(record.getMillis()));
    formatted.append(" ");
    formatted.append(record.getLevel().getName());
    formatted.append("] ");
    formatted.append(stripColors ? ConsoleColor.stripColors(formatMessage(record)) : formatMessage(record));
    formatted.append('\n');

    if(record.getThrown() != null) {
        StringWriter writer = new StringWriter();
        record.getThrown().printStackTrace(new PrintWriter(writer));
        formatted.append(writer);
    }
    return formatted.toString();
}
项目:incubator-netbeans    文件:SingleModuleProperties.java   
/** 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);
}
项目:incubator-netbeans    文件:HandlerTest.java   
public void testLoggingMessageWithBundleAndArg() throws Exception {
    FileObject dir  = TimesCollectorPeerTest.makeScratchDir(this);

    Logger LOG = Logger.getLogger("TIMER.instance.of.my.object");
    LogRecord rec = new LogRecord(Level.FINE, "LOG_ProjectWithArg"); // NOI18N
    rec.setParameters(new Object[] { dir, dir, "Lovely" });
    rec.setResourceBundle(ResourceBundle.getBundle(HandlerTest.class.getName()));
    LOG.log(rec);

    Collection<Object> files = TimesCollectorPeer.getDefault().getFiles();
    assertEquals("One object " + files, 1, files.size());

    Description descr = TimesCollectorPeer.getDefault().getDescription(files.iterator().next(), "LOG_ProjectWithArg");
    assertNotNull(descr);

    if (descr.getMessage().indexOf("My Lovely Project") == -1) {
        fail("Localized msg should contain 'My Lovely Project': " + descr.getMessage());
    }
}
项目:java-logging-benchmarks    文件:Log4JFormatter.java   
@Override
public String format(LogRecord record) {
    // %d [%t] %p %c - %m%n
    StringBuilder buf = new StringBuilder(256);
    buf.append(new Date(record.getMillis()));
    buf.append(" [");
    buf.append(
            Thread.currentThread().getId() == record.getThreadID() ? Thread.currentThread().getName() : "Unknown");
    buf.append("] ");
    buf.append(record.getLevel().getName());
    buf.append(' ');
    buf.append(record.getLoggerName());
    buf.append(" - ");
    if (record.getParameters() == null) {
        buf.append(record.getMessage());
    } else {
        buf.append(String.format(record.getMessage(), record.getParameters()));
    }
    buf.append('\n');
    return buf.toString();
}
项目:incubator-netbeans    文件:FolderObj.java   
private void createData(final File file2Create) throws IOException {
    boolean isSupported = new FileInfo(file2Create).isSupportedFile();                        
    ProvidedExtensions extensions =  getProvidedExtensions();

    if (!isSupported) {             
        extensions.createFailure(this, file2Create.getName(), false);
        FSException.io("EXC_CannotCreateData", file2Create.getName(), getPath());// NOI18N
    } else if (FileChangedManager.getInstance().exists(file2Create)) {
        extensions.createFailure(this, file2Create.getName(), false);
        SyncFailedException sfe = new SyncFailedException(file2Create.getAbsolutePath()); // NOI18N               
        String msg = NbBundle.getMessage(FileBasedFileSystem.class, "EXC_CannotCreateData", file2Create.getName(), getPath()); // NOI18N
        Exceptions.attachLocalizedMessage(sfe, msg);
        throw sfe;
    } else if (!file2Create.createNewFile()) {
        extensions.createFailure(this, file2Create.getName(), false);            
        FSException.io("EXC_CannotCreateData", file2Create.getName(), getPath());// NOI18N
    }        
    LogRecord r = new LogRecord(Level.FINEST, "DataCreated: "+ file2Create.getAbsolutePath());
    r.setParameters(new Object[] {file2Create});
    Logger.getLogger("org.netbeans.modules.masterfs.filebasedfs.fileobjects.FolderObj").log(r);        
}
项目:incubator-netbeans    文件:ConstrainedBinaryIndexerTest.java   
MockConstrainedIndexer() {
    h = new Handler() {
        @Override
        public void publish(LogRecord record) {
            if (record.getMessage().equals("RootsWork-finished")) {
                sem.release();
            }
        }
        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
        }
    };
    final Logger log = Logger.getLogger(RepositoryUpdater.class.getName() + ".tests"); //NOI18N
    log.setLevel(Level.FINEST);
    log.addHandler(h);
}
项目:incubator-netbeans    文件:ChildrenInitializedMeanwhileTest.java   
@Override
protected void setUp() throws Exception {
    EntrySupportLazy.LOGGER.addHandler(new java.util.logging.Handler() {
        {
            setLevel(Level.FINER);
            EntrySupportLazy.LOGGER.setLevel(Level.FINER);
        }
        @Override
        public void publish(LogRecord record) {
            if (record.getMessage().startsWith("setEntries():")) {
                notifyRecordIsHere();
            }
        }

        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
            throw new UnsupportedOperationException("Not supported yet.");
        }


    });
}
项目:incubator-netbeans    文件:Exceptions.java   
private void logRecords(Appendable a) {
    List<LogRecord> r = records;
    if (r == null) {
        return;
    }
    try {

        for (LogRecord log : r) {
            if (log.getMessage() != null) {
                a.append(log.getMessage()).append("\n");;
            }
            if (log.getThrown() != null) {
                StringWriter w = new StringWriter();
                log.getThrown().printStackTrace(new PrintWriter(w));
                a.append(w.toString()).append("\n");
            }
        }
    } catch (IOException ex) {
        ex.printStackTrace();
    }
}
项目:incubator-netbeans    文件:LogRecordsTest.java   
public void testNFE() throws IOException{
    InputStream stream = getClass().getResourceAsStream("issue140886");
    rec = null;
    Handler h = new Handler(){
        public void publish(LogRecord record) {
            rec = record;
        }
        @Override public void flush() {}
        @Override public void close() throws SecurityException {}
    };
    LogRecords.scan(stream, h);
    assertNotNull("Whole file is parsed", rec);
    assertEquals("UI_ACTION_EDITOR", rec.getMessage());
    assertEquals(5, rec.getParameters().length);

}
项目:incubator-netbeans    文件:MIMESupport69049Test.java   
public synchronized void publish(LogRecord r) {
    String s = r.getMessage();
    if (s.startsWith ("Computing resolvers")) {
        notifyAll();
        if (block) {
            try {
                wait(200);
            } catch (InterruptedException ex) {
                fail("Wrong exception");
            }
        }
    }

    if (s.startsWith("Resolvers computed")) {
        block = false;
        notifyAll();
    }
}
项目:incubator-netbeans    文件:UINodeTest.java   
public void testIconOfTheNode() throws Exception {
    LogRecord r = new LogRecord(Level.INFO, "icon_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", "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(n);
}
项目:Uranium    文件:ForwardLogHandler.java   
@Override
public void publish(LogRecord record) {
    Logger logger = getLogger(record.getLoggerName());
    Throwable exception = record.getThrown();
    Level level = record.getLevel();
    String message = getFormatter().formatMessage(record);

    if (level == Level.SEVERE) {
        logger.error(message, exception);
    } else if (level == Level.WARNING) {
        logger.warn(message, exception);
    } else if (level == Level.INFO) {
        logger.info(message, exception);
    } else if (level == Level.CONFIG) {
        logger.debug(message, exception);
    } else {
        logger.trace(message, exception);
    }
}
项目:stf-console-client    文件:SimpleConsoleFormatter.java   
private String formatThrowable(LogRecord record) {
    String throwable = "";
    if (record.getThrown() != null) {
        if (record.getLevel() == Level.WARNING) {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            pw.println();
            record.getThrown().printStackTrace(pw);
            pw.close();
            throwable = sw.toString();
        } else {
            throwable = record.getThrown().getMessage();
        }
    }
    return throwable;
}
项目:java-logging-benchmarks    文件:LogbackFormatter.java   
@Override
    public String format(LogRecord record) {
//        <pattern>%d{HH:mm:ss.SSS} [%t] %level{WARN=WARN_, DEBUG=DEBUG, ERROR=ERROR, TRACE=TRACE, INFO=INFO_} %c{36}
// - %m%n</pattern>

        // %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
        StringBuilder buf = new StringBuilder(256);
        buf.append(dateFmt.get().format(new Date(record.getMillis())));
        buf.append(" [");
        buf.append(
                Thread.currentThread().getId() == record.getThreadID() ? Thread.currentThread().getName() : "Unknown");
        buf.append("] ");
        buf.append(record.getLevel().getName());
        buf.append(' ');
        buf.append(abbreviateClassName(record.getLoggerName(), 36));
        buf.append(" - ");
        if (record.getParameters() == null) {
            buf.append(record.getMessage());
        } else {
            buf.append(MessageFormat.format(record.getMessage(), record.getParameters()));
        }
        buf.append('\n');
        return buf.toString();
    }
项目:incubator-netbeans    文件:LogFormatterTest.java   
public void testFormat() throws IOException {
    LogRecord rec = new LogRecord(Level.SEVERE, "PROBLEM");
    Throwable thrown = new NullPointerException("TESTING");
    thrown.initCause(new AssertionError("CAUSE PROBLEM"));
    rec.setThrown(thrown);
    String result = new LogFormatter().format(rec);
    assertTrue(result.contains("java.lang.NullPointerException: TESTING"));
    assertTrue(result.contains("<level>1000</level>"));
    assertTrue(result.contains("<method>testFormat</method>"));
    assertTrue(result.contains("<message>java.lang.AssertionError: CAUSE PROBLEM</message>"));
    assertTrue(result.contains("<more>"));
    assertTrue(result.contains("</more>"));
    assertTrue(result.contains(" <class>junit.framework.TestCase</class>"));
    assertTrue(result.contains("<class>sun.reflect.NativeMethodAccessorImpl</class>"));
    assertFalse(result.contains("<more>80</more>"));
}
项目:incubator-netbeans    文件:AfterRestartExceptions.java   
private static String getScheduledThrownClassName(LogRecord record) {
    Throwable thrown = record.getThrown();
    if (thrown == null) {
        return null;
    }
    Throwable cause;
    while (((cause = thrown.getCause()) != null) && (cause.getStackTrace().length != 0)){
        thrown = cause;
    }
    String thrownClassName = thrown.getClass().getName();
    if (scheduledThrowableClasses.contains(thrownClassName)) {
        return thrownClassName;
    } else {
        return null;
    }
}
项目:JDHttpAPI    文件:HttpAPIExtension.java   
private void startServer() {
    HttpAPIConfig cfg = getSettings();
    server = new Server(cfg.getPort());
    HandlerList lst = new HandlerList();
    LinkController ctr = new JDLinkController(LinkCollector.getInstance());
    if(cfg.getUsePassword() && cfg.getPassword() != null && !cfg.getPassword().equals("")) {
        lst.addHandler(new AuthorizationHandler(cfg.getPassword()));
    }
    lst.addHandler(new AjaxHandler(cfg.getAllowGet()));
    if(cfg.getAllowGet()) {
        lst.addHandler(new JDServerGETHandler(ctr));
    }
    lst.addHandler(new JDServerPOSTHandler(ctr));
    server.setHandler(lst);
    try {
        server.start();
    }
    catch(Exception e) {
        logger.log(new LogRecord(Level.SEVERE, e.getMessage()));
    }
}
项目:rapidminer    文件:LogHandlerModel.java   
/**
 * Adds the specified {@link LogRecord} to this model and fires an update.
 * 
 * @param record
 */
private void addLogEntry(LogRecord record) {
    LogRecordEntry newEntry = new LogRecordEntry(record);
    List<LogEntry> newLogEntries = new LinkedList<>();
    newLogEntries.add(newEntry);
    addLogEntries(newLogEntries);
}
项目:GitHub    文件:TestLogHandler.java   
@Override public void publish(LogRecord logRecord) {
  if (getFormatter() == null) {
    logs.add(logRecord.getLevel() + ": " + logRecord.getMessage());
  } else {
    logs.add(getFormatter().format(logRecord));
  }
}
项目:incubator-netbeans    文件:MessagesHandlerTest.java   
public void testLimitOfMessagesLogFiles() throws Exception {
    clearWorkDir();
    System.setProperty("netbeans.user", getWorkDirPath());
    File logs = new File(getWorkDir(), "logs");
    logs.mkdirs();

    MessagesHandler mh = new MessagesHandler(logs, 2, 16);

    mh.publish(new LogRecord(Level.INFO, "Hi"));
    mh.flush();
    assertEquals("One file", 1, logs.list().length);
    mh.publish(new LogRecord(Level.INFO, "Message that is longer than 16 bytes"));
    mh.flush();
    assertEquals("Two files", 2, logs.list().length);

    mh.publish(new LogRecord(Level.INFO, "Hello!"));
    File ml = new File(logs, "messages.log");
    mh.flush();
    String msg = readLog(ml);

    if (msg.indexOf("Hello!") == -1) {
        fail("Contains the Hello! message:\n" + msg);
    }
    if (msg.indexOf("16 bytes!") != -1) {
        fail("Contains no '16 bytes' message:\n" + msg);
    }
}
项目:incubator-netbeans    文件:SlownessReporter.java   
private String getParam(LogRecord rec, int index) {
    if (rec.getParameters() != null && rec.getParameters().length > index) {
        return rec.getParameters()[index].toString();
    } else {
        assert rec.getParameters() != null;
        assert rec.getParameters().length > index : Integer.toString(rec.getParameters().length);
    }
    return null;
}
项目:incubator-netbeans    文件:DispatchingHandlerTest.java   
@RandomlyFails // NB-Core-Build #9138, #9370: Unstable
public void testContinuousMessagesShouldNotPreventOutput() throws InterruptedException {
    class MyHandler extends Handler {
        final List<LogRecord> records = new CopyOnWriteArrayList<LogRecord>();

        @Override
        public void publish(LogRecord record) {
            records.add(record);
        }

        @Override
        public void flush() {
        }

        @Override
        public void close() throws SecurityException {
            records.clear();
        }

    }
    MyHandler mh = new MyHandler();
    DispatchingHandler dh = new DispatchingHandler(mh, 100);

    for (int i = 0; i < 100; i++) {
        dh.publish(new LogRecord(Level.INFO, "" + i));
        Thread.sleep(10);
        if (i > 50 && mh.records.isEmpty()) {
            fail("There should be some records when we are at round " + i);
        }
    }
    dh.flush();

    assertEquals("One hundered records now", 100, mh.records.size());
}
项目:incubator-netbeans    文件:Util.java   
/**
 * Disable logging of logging messages from DatabaseUILogger. See #215375.
 *
 * Usefulness of the whole logger seems to be doubtful
 */
public static void suppressSuperfluousLogging() {
    for (Handler h : Logger.getLogger("").getHandlers()) {
        h.setFilter(new Filter() {
            @Override
            public boolean isLoggable(LogRecord lr) {
                if (lr.getSourceClassName().equals("org.netbeans.modules.db.explorer.DatabaseUILogger")
                        || lr.getSourceClassName().startsWith("org.netbeans.modules.settings.RecognizeInstanceObjects")) {
                    return false;
                } else if (lr.getSourceClassName().equals(
                        "org.netbeans.api.db.sql.support.SQLIdentifiers$DatabaseMetaDataQuoter")) {
                    if (lr.getSourceMethodName().equals("getExtraNameChars")
                            && lr.getLevel() == Level.WARNING
                            && lr.getMessage().startsWith(
                                    "DatabaseMetaData.getExtraNameCharacters() failed")) {
                        return false;
                    } else if (lr.getSourceMethodName().equals("needToQuote")
                            && lr.getLevel().intValue()
                            <= Level.INFO.intValue()) {
                        return false;
                    } else {
                        return true;
                    }
                } else if (lr.getSourceClassName().equals(
                        "org.netbeans.modules.db.explorer.DatabaseConnection") &&
                        lr.getSourceMethodName().equals("doConnect")) {
                    return false;
                } else {
                    return true;
                }
            }
        });
    }
}
项目:domino    文件:SerializableLogRecordMapper.java   
public static LogRecord asLogRecord(SerializableLogRecord serializableLogRecord) {
    LogRecord logRecord = new LogRecord(Level.parse(serializableLogRecord.level), serializableLogRecord.message);
    logRecord.setLoggerName(serializableLogRecord.loggerName);
    logRecord.setMillis(serializableLogRecord.millis);
    logRecord.setThrown(JsonLogRecordThrowable.fromJsonString(serializableLogRecord.thrown));
    return logRecord;
}
项目:L2jBrasil    文件:L2ItemInstance.java   
/**
 * Sets the ownerID of the item
 * @param process : String Identifier of process triggering this action
 * @param owner_id : int designating the ID of the owner
 * @param creator : L2PcInstance Player requesting the item creation
 * @param reference : L2Object Object referencing current action like NPC selling item or previous item in transformation
 */
public void setOwnerId(String process, int owner_id, L2PcInstance creator, L2Object reference)
{
    setOwnerId(owner_id);
    if (Config.LOG_ITEMS)
    {
        LogRecord record = new LogRecord(Level.INFO, "CHANGE:" + process);
        record.setLoggerName("item");
        record.setParameters(new Object[]{this, creator, reference});
        _logItems.log(record);
    }
}
项目:incubator-netbeans    文件:LookupSensitiveActionUILogTest.java   
public void testToolbarPushIsNotified() throws Exception {
       TestSupport.ChangeableLookup lookup = new TestSupport.ChangeableLookup();
       TestLSA tlsa = new TestLSA( lookup );
assertTrue ("TestLSA action is enabled.", tlsa.isEnabled ());
tlsa.refreshCounter = 0;
       TestPropertyChangeListener tpcl = new TestPropertyChangeListener();
       tlsa.addPropertyChangeListener( tpcl );
       lookup.change(d2);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );
       assertTrue("Action is enabled", tlsa.isEnabled());

       tlsa.setDisplayName("Jarda");

       JToolBar bar = new JToolBar();
       JButton item = bar.add(tlsa);
       item.doClick();

       assertEquals("One record logged:\n" + my.recs, 1, my.recs.size());
       LogRecord r = my.recs.get(0);
       assertEquals("Menu push", "UI_ACTION_BUTTON_PRESS", r.getMessage());
       assertEquals("four args", 5, r.getParameters().length);
       assertEquals("first is the menu item", item, r.getParameters()[0]);
       assertEquals("second is its class", item.getClass().getName(), r.getParameters()[1]);
       assertEquals("3rd is action", tlsa, r.getParameters()[2]);
       assertEquals("4th its class", tlsa.getClass().getName(), r.getParameters()[3]);
       assertEquals("5th name", "Jarda", r.getParameters()[4]);

       tlsa.clear();
       tpcl.clear();
       lookup.change(d3);
       assertEquals( "Refresh should be called once", 1, tlsa.refreshCounter );
       assertEquals( "One event should be fired", 1, tpcl.getEvents().size() );        
   }
项目:openjdk-jdk10    文件:PlatformLoggerBridgeTest.java   
@Override
public void publish(LogRecord record) {
    eventQueue.add(LogEvent.of(sequencer.getAndIncrement(),
            true, record.getLoggerName(),
            record.getSourceClassName(),
            record.getSourceMethodName(),
            PlatformLogger.Level.valueOf(record.getLevel().getName()),
            record.getResourceBundle(), record.getMessage(),
            record.getThrown(), record.getParameters()));
}
项目:incubator-netbeans    文件:InteceptorTest.java   
public void publish(LogRecord rec) {
    try {
        Thread.sleep(1000);
    } catch (InterruptedException ex) {
        Exceptions.printStackTrace(ex);
    }
}
项目:incubator-netbeans    文件:LogUtils.java   
/**
 * Logs bugtracking events
 *
 * @param key - the events key
 * @param parameters - the parameters for the given event
 */
private static void logBugtrackingEvents(String key, Object[] parameters) {
    LogRecord rec = new LogRecord(Level.INFO, key);
    rec.setParameters(parameters);
    rec.setLoggerName(METRICS_LOG.getName());
    METRICS_LOG.log(rec);
}
项目:incubator-netbeans    文件:Logo.java   
@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 );
}
项目:incubator-netbeans    文件:DefaultSourceLevelQueryImplTest.java   
@Override
public void publish(LogRecord record) {
    final String msg = record.getMessage();
    if (msg != null) {
        switch (msg) {
            case "rootCache updated: {0}":
                roots.add((FileObject)record.getParameters()[0]);
                break;
            case "modCache updated: {0}":
                isModular.add((Boolean)record.getParameters()[0]);
                break;
        }
    }
}
项目:domino    文件:RestfulRemoteLogHandler.java   
private SerializableLogRecord asSerializableLogRecord(LogRecord record) {
    SerializableLogRecord serializableLogRecord = new SerializableLogRecord();
    serializableLogRecord.level = record.getLevel().toString();
    serializableLogRecord.millis = record.getMillis();
    serializableLogRecord.message = record.getMessage();
    serializableLogRecord.loggerName = record.getLoggerName();
    serializableLogRecord.permutationStrongName = GWT.getPermutationStrongName();
    serializableLogRecord.thrown = serializableThrowable(unwrap(record.getThrown()));
    return serializableLogRecord;
}
项目:incubator-netbeans    文件:MimePathLookupTest.java   
@Override
public void publish(LogRecord record) {
    final String message = record.getMessage();
    if (message.startsWith("Rebuilding MimeLookup for") && Thread.currentThread().getName().equals("Thread 1")) {
        try {
            // System.out.println("Publish enter");
            barrier.await();
            // System.out.println("Publish waiting");
            Thread.sleep(5000); // Give the other thread a chance to deadlock
            // System.out.println("Publish exit");
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}