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


Java Level.SEVERE属性代码示例

本文整理汇总了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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:LoggingTest.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:NbErrorManager.java

示例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>");
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:InstallerReadPageTest.java

示例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);
}
 
开发者ID:Piasy,项目名称:AppRTC-Android,代码行数:24,代码来源:Logging.java

示例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) {}
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:19,代码来源:SamaGamesAPI.java

示例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;
}
 
开发者ID:gurkenlabs,项目名称:litiengine,代码行数:8,代码来源:ConsoleLogHandler.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:LogRecordsTest.java

示例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());
}
 
开发者ID:AlphaHelixDev,项目名称:AlphaLibary,代码行数:15,代码来源:AddonLogger.java

示例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;
}
 
开发者ID:gabixdev,项目名称:Kyoko,代码行数:10,代码来源:ColoredFormatter.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:InstallerTest.java

示例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();
    }
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:33,代码来源:Log.java

示例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);
        }
    }

}
 
开发者ID:YcheCourseProject,项目名称:DIA-Umpire-Maven,代码行数:36,代码来源:DocumentHandler.java

示例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));
  }
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:10,代码来源:RenderKitTestCase.java

示例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);
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:7,代码来源:JdkLoggingImpl.java

示例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();
    }
}
 
开发者ID:Alvin-LB,项目名称:NameTagChanger,代码行数:11,代码来源:ChannelPacketHandler.java


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