当前位置: 首页>>代码示例>>Java>>正文


Java LogRecord.getThrown方法代码示例

本文整理汇总了Java中java.util.logging.LogRecord.getThrown方法的典型用法代码示例。如果您正苦于以下问题:Java LogRecord.getThrown方法的具体用法?Java LogRecord.getThrown怎么用?Java LogRecord.getThrown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.LogRecord的用法示例。


在下文中一共展示了LogRecord.getThrown方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: format

import java.util.logging.LogRecord; //导入方法依赖的package包/类
/**
 * Format the log record as follows:
 *
 *     Date Level Message ExceptionTrace
 *
 * @param       logRecord       The log record
 * @return                      The formatted string
 */
@Override
public String format(LogRecord logRecord) {
    Object[] arguments = new Object[4];
    arguments[0] = new Date(logRecord.getMillis());
    arguments[1] = logRecord.getLevel().getName();
    arguments[2] = logRecord.getMessage();
    Throwable exc = logRecord.getThrown();
    if (exc != null) {
        Writer result = new StringWriter();
        exc.printStackTrace(new PrintWriter(result));
        arguments[3] = result.toString();
    } else {
        arguments[3] = "";
    }
    return messageFormat.get().format(arguments);
}
 
开发者ID:muhatzg,项目名称:burstcoin,代码行数:25,代码来源:BriefLogFormatter.java

示例2: publish

import java.util.logging.LogRecord; //导入方法依赖的package包/类
public void publish(LogRecord record) {
    messages.append(record.getMessage());
    
    lastText = record.getMessage();
    lastThrowable = record.getThrown();

    Level l = record.getLevel();
    if (l.intValue() >= Level.FINEST.intValue()) {
        lastSeverity = ErrorManager.INFORMATIONAL;
    }
    if (l.intValue() >= Level.WARNING.intValue()) {
        lastSeverity = ErrorManager.WARNING;
    }
    if (l.intValue() >= Level.SEVERE.intValue()) {
        lastSeverity = ErrorManager.EXCEPTION;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:ErrorManagerDelegatesToLoggingTest.java

示例3: logRecords

import java.util.logging.LogRecord; //导入方法依赖的package包/类
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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:UIExceptions.java

示例4: format

import java.util.logging.LogRecord; //导入方法依赖的package包/类
@Override
public String format(LogRecord record) {
    StringBuilder builder = new StringBuilder();

    builder.append(DATE.format(record.getMillis()));
    builder.append(" [");
    builder.append(record.getLevel().getLocalizedName());
    builder.append("] ");
    builder.append(formatMessage(record));
    builder.append('\n');

    if (record.getThrown() != null) {
        StringWriter writer = new StringWriter();
        record.getThrown().printStackTrace(new PrintWriter(writer));
        builder.append(writer);
    }

    return builder.toString();
}
 
开发者ID:Dragovorn,项目名称:courier,代码行数:20,代码来源:CourierFormatter.java

示例5: testInitFile_NotFound

import java.util.logging.LogRecord; //导入方法依赖的package包/类
@Test
public void testInitFile_NotFound() throws Exception {
  // Construct the file name but not the file
  String initFileName = temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath()
      + File.separator + INIT_FILE_NAME;

  /*
   * String historyFileName, String defaultPrompt, int historySize, String logDir, Level logLevel,
   * Integer logLimit, Integer logCount, String initFileName
   */
  GfshConfig gfshConfig = new GfshConfig(this.gfshHistoryFileName, "", 0,
      temporaryFolder_CurrentDirectory.getRoot().getAbsolutePath(), null, null, null,
      initFileName);
  assertNotNull(INIT_FILE_NAME, gfshConfig.getInitFileName());

  /*
   * boolean launchShell, String[] args, GfshConfig gfshConfig
   */
  Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig);

  int actualStatus = gfsh.getLastExecutionStatus();
  int expectedStatus = 0;
  assertNotEquals("Status <0==failure", expectedStatus, actualStatus);

  int expectedLogCount = BANNER_LINES + INIT_FILE_CITATION_LINES + 1;
  assertEquals("Log records written", expectedLogCount, this.junitLoggerHandler.getLog().size());
  Throwable exception = null;
  for (LogRecord logRecord : this.junitLoggerHandler.getLog()) {
    if (logRecord.getThrown() != null) {
      exception = logRecord.getThrown();
      break;
    }
  }
  assertNotNull("Exceptions in log", exception);
}
 
开发者ID:ampool,项目名称:monarch,代码行数:36,代码来源:GfshInitFileJUnitTest.java

示例6: log

import java.util.logging.LogRecord; //导入方法依赖的package包/类
public void log(LogRecord record) {
    init();

    errorManager.log(((Integer)levelMap.get(record.getLevel())).intValue(),
        formatter.format(record));
    
    if (record.getThrown() != null) {
        errorManager.notify(((Integer)exceptionLevelMap.get(
            record.getLevel())).intValue(), record.getThrown());
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ErrorManagerCyclicDepTest.java

示例7: 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

示例8: format

import java.util.logging.LogRecord; //导入方法依赖的package包/类
public synchronized String format(LogRecord record) {

		final String sourceClassName = record.getSourceClassName();
		final String sourceMethodName = record.getSourceMethodName();

		mCalendar.setTimeInMillis(record.getMillis());

		final StringBuilder sb = new StringBuilder();
		sb.append(String.format("%1$tD %1$tT.%1$tL [%2$6s] ", mCalendar, record.getLevel().toString()));

		if (sourceClassName != null) {
			sb.append(sourceClassName);
		} else {
			String loggerName = record.getLoggerName();
			sb.append(loggerName);
		}
		sb.append(" ");

		if (sourceMethodName != null) {
			sb.append(String.format("#%s", sourceMethodName));
		}
		sb.append(" ");
		sb.append(formatMessage(record));
		sb.append("\n");
		Throwable thrown = record.getThrown();
		if (thrown != null) {
			sb.append(record.getThrown());
		}
		return sb.toString();
	}
 
开发者ID:riversun,项目名称:java-firebase-fcm-client,代码行数:31,代码来源:LogFormatter.java

示例9: popLoggedThrowable

import java.util.logging.LogRecord; //导入方法依赖的package包/类
private Throwable popLoggedThrowable() {
  List<LogRecord> logRecords = logHandler.getStoredLogRecords();
  assertEquals(1, logRecords.size());
  LogRecord logRecord = logRecords.get(0);
  logHandler.clear();
  return logRecord.getThrown();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:CacheLoadingTest.java

示例10: format

import java.util.logging.LogRecord; //导入方法依赖的package包/类
/**
 * Format the given LogRecord.
 * @param record the log record to be formatted.
 * @return a formatted log record
 */
@Override
public synchronized String format(LogRecord record)
{
    date.setTime(record.getMillis());
    StringBuffer sb = new StringBuffer(dformat.format(date));
    if (record.getLoggerName() != null)
        sb.append(" " + record.getLoggerName());
    if (record.getSourceMethodName() != null)
        sb.append(" " + record.getSourceMethodName());
    sb.append(" " + record.getLevel().getLocalizedName() + ": ");
    sb.append(formatMessage(record).replaceAll("[\b]", ""));
    sb.append("\n");

    if (record.getThrown() != null)
    {
        try
        {
            StringWriter sw = new StringWriter();
            PrintWriter pw = new PrintWriter(sw);
            record.getThrown().printStackTrace(pw);
            pw.close();
            sb.append(sw.toString());
        }
        catch (Exception ex)
        {
        }
    }

    return sb.toString();
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:36,代码来源:AppSetup.java

示例11: publish

import java.util.logging.LogRecord; //导入方法依赖的package包/类
public void publish(LogRecord record) {
    if (record.getThrown() != null) {
        Level level = record.getLevel();
        if (level.intValue() == Level.WARNING.intValue() + 1) {
            // unknown level
            level = null;
        }
        if (level != null && level.intValue() == Level.SEVERE.intValue() + 1) {
            // unknown level
            level = null;
        }
        Exc ex = createExc(record.getThrown(), level, record.getLevel().intValue() == 1973 ? record : null);
        NotifyExcPanel.notify(ex);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:NbErrorManager.java

示例12: format

import java.util.logging.LogRecord; //导入方法依赖的package包/类
public String format(LogRecord record) {
    StringBuilder sb = new StringBuilder();
    if (withTime) {
        sb.append(sdf.format(new Date(record.getMillis())) + "  ");
    }
    sb.append(record.getLevel() + "  " + formatMessage(record));
    if (record.getThrown() != null) {
        StringWriter sw = new StringWriter();
        record.getThrown().printStackTrace(new PrintWriter(sw));
        sb.append(LS + sw);
    }
    return sb.toString() + LS;
    // This uses platform-specific line-separator, the same as
    // SimpleLogger does.
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:16,代码来源:BasicTextJdkLogFormatter.java

示例13: create

import java.util.logging.LogRecord; //导入方法依赖的package包/类
static Node create(LogRecord r) {
    Children ch;
    if (r.getThrown() != null) {
        ch = new StackTraceChildren(r.getThrown());
    } else if ("UI_ENABLED_MODULES".equals(r.getMessage()) || 
        "UI_DISABLED_MODULES".equals(r.getMessage())) {
        ch = new ModulesChildren(r.getParameters());
    } else {
        ch = Children.LEAF;
    }
    
    
    return new UINode(r, ch);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:UINode.java

示例14: publish

import java.util.logging.LogRecord; //导入方法依赖的package包/类
/**
 * Publishes the given LogRecord by writing its data to a file using a
 * TextFormatter.
 * 
 * @param record The {@code LogRecord} to publish.
 */
@Override
public void publish(LogRecord record) {
    if (record.getLevel().intValue() < getLevel().intValue()
        && record.getThrown() == null) {
        return;
    }

    String str = getFormatter().format(record);
    if (consoleLogging
        && record.getLevel().intValue() >= Level.WARNING.intValue()) {
        System.err.println(str);
    }

    synchronized (this.writerLock) {
        if (this.writer != null) {
            try {
                this.writer.write(str, 0, str.length());
                // Because FreeCol is still in a very early stage.
                flush();
            } catch (IOException ioe) {
                System.err.println("Failed to write log record: " + str);
                ioe.printStackTrace(System.err);
            }
        }
    }

    // Do this last, as it might shut down a debug run
    Throwable t = record.getThrown();
    if (t != null && !(t instanceof FreeColException
            && ((FreeColException)t).debugAllowed())) {
        FreeColDebugger.handleCrash();
    }
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:40,代码来源:DefaultHandler.java

示例15: getThrown

import java.util.logging.LogRecord; //导入方法依赖的package包/类
@Override
public Throwable getThrown(LogRecord res) {
    return res.getThrown();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:5,代码来源:LoggerFinderBackendTest.java


注:本文中的java.util.logging.LogRecord.getThrown方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。