當前位置: 首頁>>代碼示例>>Java>>正文


Java LogRecord.getMessage方法代碼示例

本文整理匯總了Java中java.util.logging.LogRecord.getMessage方法的典型用法代碼示例。如果您正苦於以下問題:Java LogRecord.getMessage方法的具體用法?Java LogRecord.getMessage怎麽用?Java LogRecord.getMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.logging.LogRecord的用法示例。


在下文中一共展示了LogRecord.getMessage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public synchronized void publish(LogRecord record) {
    final String message = record.getMessage();
    if (JFXApplicationClassChooser.LOG_INIT.equals(message)) {
        callInterceptor(0);
    } else if (JFXApplicationClassChooser.LOG_MAIN_CLASSES.equals(message)) {
        callInterceptor(1);
        final String[] result = ((Set<String>)record.getParameters()[0]).toArray(new String[0]);
        final boolean scan = (Boolean) record.getParameters()[1];
        final String[] expected = mainClasses.removeFirst();
        Arrays.sort(result);
        Arrays.sort(expected);
        final boolean last = mainClasses.isEmpty();
        if (last == scan) {
            failure = "Expected " + (!last) + ", Result: " + scan;  //NOI18N
            notifyAll();
        } else if (!Arrays.equals(expected, result)) {
            failure = "Expected " + Arrays.toString(expected) + ", Result: " + Arrays.toString(result); //NOI18N
            notifyAll();
        } else if (last) {
            notifyAll();
        }                
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:JFXApplicationClassChooserTest.java

示例2: testOwnFormatter

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public void testOwnFormatter() throws UnsupportedEncodingException {
    class MyFrmtr extends Formatter {
        private int cnt;
        @Override
        public String format(LogRecord record) {
            cnt++;
            return record.getMessage();
        }
    }
    MyFrmtr my = new MyFrmtr();
    
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    StreamHandler sh = new StreamHandler(os, NbFormatter.FORMATTER);
    DispatchingHandler dh = new DispatchingHandler(sh, 10);
    dh.setFormatter(my);
    dh.publish(new LogRecord(Level.WARNING, "Ahoj"));
    dh.flush();
    String res = new String(os.toByteArray(), "UTF-8");
    assertEquals("Only the message is written", "Ahoj", res);
    assertEquals("Called once", 1, my.cnt);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:DispatchingHandlerTest.java

示例3: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    String message = record.getMessage();
    if (message.startsWith("refreshAll: starting status scan for ") && (
            message.contains(workdirFO.getPath() + ",")
            || message.contains(workdirFO.getPath() + "]")
            || message.contains(modifiedFile.getParentFile().getParentFile().getAbsolutePath()))) {
        refreshStarted = true;
        refreshString = message;
    } else if (refreshStarted && message.startsWith("refreshAll: finishes status scan after ")) {
        refreshed = true;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:ExternalChangesTest.java

示例4: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    final String msg = record.getMessage();
    if (msg != null) {
        final Action action = actions.get(msg);
        if (action != null) {
            try {
                action.run(record.getParameters());
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:CancelSupportTest.java

示例5: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    String msg = record.getMessage();
    String method = record.getSourceMethodName();
    String className = record.getSourceClassName();
    if (msg.contains(illegal)) {
        testFailed = true;
    }
    if (msg.contains("attribute names=")) {
        System.err.println("LOG: " + className + "." + method + ": " + msg);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:13,代碼來源:TestLogHandler.java

示例6: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    String msg = record.getMessage();
    assertFalse("Duplicate scan of project tree detected: " + msg,
            msg.startsWith("Warning: two modules found with the same code name base"));
    if (msg.startsWith("scanPossibleProject: ") && msg.endsWith("scanned successfully")
            && ! scannedDirs.add(msg)) {
        error = "scanPossibleProject already run: " + msg;
    }
    if (msg.startsWith("scanCluster: ") && msg.endsWith(" succeeded.")
            && ! scannedDirs.add(msg)) {
        error = "scanCluster already run: " + msg;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:ModuleListTest.java

示例7: isLoggable

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public boolean isLoggable(LogRecord record) {
    String msg = record.getMessage();
    if (msg != null && msg.contains(targetMessage)) {
        messageCount.incrementAndGet();
    }

    return true;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:10,代碼來源:TestWebappClassLoaderThreadLocalMemoryLeak.java

示例8: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {            
    String msg = record.getMessage();
    if(msg == null || msg.trim().equals("")) {
        return;
    }
    if(msg.startsWith("refreshRecursively")) {
        methodNames.add("refreshRecursively");
    } else if(msg.startsWith("needsLocalHistory")) {
        methodNames.add((String) record.getParameters()[0]);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:FSInterceptorTest.java

示例9: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    lastBundle = record.getResourceBundle();
    lastBundleName = record.getResourceBundleName();
    lastParams = record.getParameters();
    lastThrown = record.getThrown();
    lastMessage = record.getMessage();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:9,代碼來源:TestLogrbResourceBundle.java

示例10: JMXLogPublisher

import java.util.logging.LogRecord; //導入方法依賴的package包/類
/**
 * Initialize publisher with the simplest formatter - just publishing the message.
 */
public JMXLogPublisher() {
	super(new Formatter(){
		@Override
		public String format(LogRecord record) {				
			return record.getMessage();
		}			
	});
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:12,代碼來源:JMXLogPublisher.java

示例11: toString

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public static StringBuffer toString(LogRecord record) {
    StringBuffer sb = new StringBuffer();
    sb.append('[');
    sb.append(record.getLoggerName());
    sb.append("] THREAD: ");
    sb.append(Thread.currentThread().getName());
    sb.append(" MSG: ");
    String txt = record.getMessage();
    ResourceBundle b = record.getResourceBundle();
    if (b != null) {
        try {
            txt = b.getString(txt);
        } catch (MissingResourceException ex) {
            // ignore
        }
    }
    if (txt != null && record.getParameters() != null) {
        txt = MessageFormat.format(txt, record.getParameters());
    }
    sb.append(txt);
    Throwable t = record.getThrown();
    if (t != null) {
        sb.append('\n');
        StringWriter w = new StringWriter();
        t.printStackTrace(new PrintWriter(w));
        sb.append(w.toString().replace("\tat ", "  ").replace("\t... ", "  ... "));
    }
    sb.append('\n');
    return sb;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:NbModuleLogHandler.java

示例12: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record)
{
	String message = record.getMessage();
	Throwable exception = record.getThrown();
	Level level = record.getLevel();

	org.apache.log4j.Logger log4j = org.apache.log4j.Logger.getLogger("TomcatLog");

	// if tomcat log is not configured
	if( log4j == null )
	{
		return;
	}

	if( level == Level.SEVERE )
	{
		log4j.error(message, exception);
	}
	else if( level == Level.WARNING )
	{
		log4j.warn(message, exception);
	}
	else if( level == Level.INFO )
	{
		log4j.info(message, exception);
	}
	else if( level == Level.CONFIG )
	{
		log4j.debug(message, exception);
	}
	else
	{
		log4j.trace(message, exception);
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:37,代碼來源:TomcatLogRedirector.java

示例13: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
    final String msg = record.getMessage();
    if (msg != null && msg.startsWith("runTargets:")) { //NOI18N
        props.putAll((Properties)record.getParameters()[1]);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:BaseActionProviderTest.java

示例14: format

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public String format(LogRecord record) {
	return record.getLevel() + ": " 
			// + record.getSourceClassName() +": " 
			+ record.getMessage() + "\n";  
}
 
開發者ID:aswroma3,項目名稱:asw,代碼行數:6,代碼來源:TextFormatter.java

示例15: publish

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public final void publish(LogRecord record) {
    String recordMsg = record.getMessage();
    if (recordMsg != null && recordMsg.indexOf(this.message) != -1) {
        processLogRecord(record);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:7,代碼來源:FolderObjTest.java


注:本文中的java.util.logging.LogRecord.getMessage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。