本文整理匯總了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();
}
}
}
示例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);
}
示例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;
}
}
示例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);
}
}
}
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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]);
}
}
示例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();
}
示例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();
}
});
}
示例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;
}
示例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);
}
}
示例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]);
}
}
示例14: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
public String format(LogRecord record) {
return record.getLevel() + ": "
// + record.getSourceClassName() +": "
+ record.getMessage() + "\n";
}
示例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);
}
}