本文整理汇总了Java中java.util.logging.Level.SEVERE属性的典型用法代码示例。如果您正苦于以下问题:Java Level.SEVERE属性的具体用法?Java Level.SEVERE怎么用?Java Level.SEVERE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.util.logging.Level
的用法示例。
在下文中一共展示了Level.SEVERE属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFmting
public void testFmting() throws Exception {
Logger log = Logger.getLogger(getName());
LogRecord rec = new LogRecord(Level.SEVERE, "LOG_SevereMsg");
rec.setResourceBundle(ResourceBundle.getBundle("org.netbeans.junit.TestBundle"));
rec.setParameters(new Object[] { "Very" });
log.log(rec);
File f = new File(getWorkDir(), getName() + ".log");
assertEquals("Log file exists", true, f.exists());
byte[] arr = new byte[(int)f.length()];
FileInputStream is = new FileInputStream(f);
int l = is.read(arr);
assertEquals(l, arr.length);
String s = new String(arr);
if (s.indexOf("Important message Very") == -1) {
fail("There should the message\n" + s);
}
}
示例2: getSeverity
/** @return the severity of the exception */
Level getSeverity() {
if (severity != null) {
return severity;
}
LogRecord[] anns = (arrAll != null) ? arrAll : arr;
for (int i = 0; i < anns.length; i++) {
Level s = anns[i].getLevel();
if (severity == null || s.intValue() > severity.intValue()) {
severity = s;
}
}
if (severity == null || severity == Level.ALL) {
// no severity specified, assume this is an error
severity = t instanceof Error ? Level.SEVERE : Level.WARNING;
}
return severity;
}
示例3: testSendLogWithException
@RandomlyFails // NB-Core-Build #7964
public void testSendLogWithException() throws Exception {
Logger uiLogger = Logger.getLogger(Installer.UI_LOGGER_NAME);
LogRecord log1 = new LogRecord(Level.SEVERE, "TESTING MESSAGE");
LogRecord log2 = new LogRecord(Level.SEVERE, "TESTING MESSAGE");
LogRecord log3 = new LogRecord(Level.SEVERE, "NO EXCEPTION LOG");
LogRecord log4 = new LogRecord(Level.INFO, "INFO");
Throwable t1 = new NullPointerException("TESTING THROWABLE");
Throwable t2 = new UnknownError("TESTING ERROR");
log1.setThrown(t1);
log2.setThrown(t2);
log4.setThrown(t2);
Installer installer = Installer.findObject(Installer.class, true);
assertNotNull(installer);
installer.restored();
uiLogger.log(log1);
uiLogger.log(log2);
uiLogger.log(log3);
UIHandler.waitFlushed();
if (Installer.getThrown() == null) {
fail("Exception should be found in the log");
}
doEncodingTest("UTF-8", "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'></meta>");
}
示例4: log
public static void log(Severity severity, String tag, String message) {
if (loggingEnabled) {
nativeLog(severity.ordinal(), tag, message);
return;
}
// Fallback to system log.
Level level;
switch (severity) {
case LS_ERROR:
level = Level.SEVERE;
break;
case LS_WARNING:
level = Level.WARNING;
break;
case LS_INFO:
level = Level.INFO;
break;
default:
level = Level.FINE;
break;
}
fallbackLogger.log(level, tag + ": " + message);
}
示例5: slackLog
public void slackLog(Level level, SlackMessage message)
{
String color;
if (level == Level.FINE)
color = "#2FA44F";
else if (level == Level.WARNING)
color = "#DE9E31";
else if (level == Level.SEVERE)
color = "#D50200";
else
color = "#28D7E5";
try
{
this.getSlackLogsPublisher().push(new SlackAttachment("").color(color).text(message));
}
catch (IOException ignored) {}
}
示例6: getColor
private static Color getColor(Level level) {
if (level == Level.SEVERE) {
return Color.RED;
} else if (level == Level.WARNING) {
return Color.ORANGE;
} else
return Color.LIGHT_GRAY;
}
示例7: randomLevel
private static Level randomLevel(Random r) {
int lev = r.nextInt(1100);
if (lev >= Level.SEVERE.intValue()) return Level.SEVERE;
if (lev >= Level.WARNING.intValue()) return Level.WARNING;
if (lev >= Level.INFO.intValue()) return Level.INFO;
if (lev >= Level.CONFIG.intValue()) return Level.CONFIG;
if (lev >= Level.FINE.intValue()) return Level.FINE;
if (lev >= Level.FINER.intValue()) return Level.FINER;
if (lev >= Level.FINEST.intValue()) return Level.FINEST;
return Level.OFF;
}
示例8: log
public void log(Level level, String msg) {
StringBuilder builder = new StringBuilder();
builder.append(PREFIX);
if (level == Level.INFO) {
builder.append(INFO);
}
if (level == Level.SEVERE) {
builder.append(ERROR);
}
builder.append(" ").append(msg);
System.out.println(builder.toString());
}
示例9: getColor
private String getColor(Level l) {
if (l == Level.SEVERE) // why that's not enum ;/
return ERROR_COLOR;
else if (l == Level.WARNING)
return WARNING_COLOR;
else if (l == Level.INFO)
return INFO_COLOR;
else
return DEBUG_COLOR;
}
示例10: testCreateMessageIssue160019
public void testCreateMessageIssue160019() throws IOException {//ignore annotations
final List<LogRecord> logs = new ArrayList<LogRecord>();
ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
Exception rootExc = new NullPointerException("root");
Exceptions.attachMessage(rootExc, "annotation message");
LogRecord rec = new LogRecord(Level.SEVERE, "test");
rec.setThrown(rootExc);
LogRecords.write(bos, rec);
bos.close();
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
LogRecords.scan(bis, new Handler() {
@Override
public void publish(LogRecord record) {
logs.add(record);
}
@Override
public void flush() {
}
@Override
public void close() throws SecurityException {
}
});
bis.close();
assertEquals(1, logs.size());
Throwable thrown = logs.get(0).getThrown();
assertEquals("thrown is annotated", "annotation message", thrown.getCause().getMessage());
String message = Installer.createMessage(thrown);
assertEquals("annontation should be ignored", "NullPointerException: root", message);
}
示例11: write
private void write(final Level level, final String message, final String jobName, final Object... args) {
for (int i = 0; i < args.length; i++) {
if (args[i] instanceof SQSTriggerQueue) {
args[i] = ((SQSTriggerQueue) args[i]).getUrl();
}
else if (args[i] instanceof Throwable) {
args[i] = ExceptionUtils.getStackTrace((Throwable)args[i]);
}
}
StringBuilder source = new StringBuilder();
if (this.autoFormat) {
final String id = String.format("%06X", Thread.currentThread().getId());
source
.append("[").append(ClassUtils.getAbbreviatedName(this.clazz, 1)).append("]")
.append("[thread-").append(id).append("]");
if (StringUtils.isNotBlank(jobName)) {
source.append("[job-").append(jobName).append("]");
}
}
String msg = String.format(message, args);
if (level == Level.CONFIG) {
msg = "[DEBUG] " + msg;
} else if (level == Level.SEVERE) {
msg = "[ERROR] " + msg;
}
this.logger.logp(level, source.toString(), "", msg);
if (this.streamHandler != null) {
this.streamHandler.flush();
}
}
示例12: publish
/**
*
*/
public void publish(LogRecord record) {
if (!isLoggable(record)) {
return;
}
String message;
try {
message = getFormatter().format(record);
} catch (Exception exception) {
reportError(null, exception, ErrorManager.FORMAT_FAILURE);
return;
}
synchronized (textPane) {
if (textPane.getDocument().getLength() >= MAXIMUM_DOCUMENT_SIZE) {
// Delete the contents of the text pane.
textPane.setText("");
}
try {
if (record.getLevel() == Level.SEVERE) {
textPane.getDocument().insertString(textPane.getDocument().getLength(), message, severStyle);
} else {
textPane.getDocument().insertString(textPane.getDocument().getLength(), message, infoStyle);
}
textPane.setCaretPosition(textPane.getDocument().getLength());
} catch (Exception ex) {
reportError(null, ex, ErrorManager.WRITE_FAILURE);
}
}
}
示例13: publish
@Override
public void publish(LogRecord record)
{
if (record.getLevel() == Level.SEVERE)
{
String message = (new SimpleFormatter()).format(record);
_result.addError(BaseTest.this,
new AssertionFailedError(message));
}
}
示例14: error
public void error(String s, Throwable e) {
LogRecord lr = new LogRecord(Level.SEVERE, s);
lr.setSourceClassName(log.getName());
lr.setThrown(e);
log.log(lr);
}
示例15: logMessage
@Override
protected void logMessage(Level level, String message, Exception e) {
if (level == Level.SEVERE) {
System.err.println("[NameTagChanger] " + message);
} else {
NameTagChanger.INSTANCE.printMessage(message);
}
if (e != null) {
e.printStackTrace();
}
}