本文整理匯總了Java中java.util.logging.LogRecord.getLevel方法的典型用法代碼示例。如果您正苦於以下問題:Java LogRecord.getLevel方法的具體用法?Java LogRecord.getLevel怎麽用?Java LogRecord.getLevel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.logging.LogRecord
的用法示例。
在下文中一共展示了LogRecord.getLevel方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override public synchronized String format(LogRecord record){
StringBuilder sb=new StringBuilder();
Level l=record.getLevel();
boolean warning=false; // we indent warning to make them stand out
if(l.intValue()>=Level.WARNING.intValue()) {
sb.append(" ******");
warning=true;
}
sb.append(super.format(record)); // prepend marker " ******", then append 1st line warning
int nl=sb.indexOf("\n");
while(nl>=1){
sb.replace(nl, nl+1, ": ");
nl=sb.indexOf("\n");
}
sb.append("\n");
String s=sb.toString();
// if(warning) {
// s=s.replaceFirst("\n"," \n"); // replace newlines with " \n"
// }
// s=s.replace("\n",": ");
return s;
}
示例2: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
if ("Cannot add filesystem watch for {0}: {1}"
.equals(record.getMessage())) {
Level f = record.getLevel();
if (Level.WARNING.equals(f)) {
warning++;
} else if (Level.INFO.equals(f)) {
info++;
} else if (Level.FINE.equals(f)) {
fine++;
} else {
other++;
}
}
}
示例3: LogRecordEntry
import java.util.logging.LogRecord; //導入方法依賴的package包/類
/**
* Creates a new {@link LogRecordEntry} which automatically formats the given {@link LogRecord}
* with the RapidMiner Studio log styling and default logging format.
*
* @param logRecord
*/
public LogRecordEntry(LogRecord logRecord) {
logLevel = logRecord.getLevel();
initialString = logRecord.getMessage();
simpleAttributeSet = new SimpleAttributeSet();
if (logRecord.getLevel().intValue() >= Level.SEVERE.intValue()) {
StyleConstants.setForeground(simpleAttributeSet, COLOR_ERROR);
StyleConstants.setBold(simpleAttributeSet, true);
} else if (logRecord.getLevel().intValue() >= Level.WARNING.intValue()) {
StyleConstants.setForeground(simpleAttributeSet, COLOR_WARNING);
StyleConstants.setBold(simpleAttributeSet, true);
} else if (logRecord.getLevel().intValue() >= Level.INFO.intValue()) {
StyleConstants.setForeground(simpleAttributeSet, COLOR_INFO);
StyleConstants.setBold(simpleAttributeSet, false);
} else {
StyleConstants.setForeground(simpleAttributeSet, COLOR_DEFAULT);
StyleConstants.setBold(simpleAttributeSet, false);
}
formattedString = formatter.format(logRecord);
}
示例4: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record) {
if (!isLoggable(record)) {
return;
}
int severity = IStatus.INFO;
if (record.getLevel() == Level.SEVERE) {
severity = IStatus.ERROR;
} else if (record.getLevel() == Level.WARNING) {
severity = IStatus.WARNING;
}
IStatus status = new Status(severity, record.getLoggerName(), record.getMessage(), record.getThrown());
Platform.getLog(JavaDebuggerServerPlugin.context.getBundle()).log(status);
}
示例5: createRepeatingRecord
import java.util.logging.LogRecord; //導入方法依賴的package包/類
private LogRecord createRepeatingRecord(LogRecord r, long rc) {
if (lastRecordAllRepeatsCounter <= (MAX_REPEAT_COUNT_FLUSH+1)) {
return new LogRecord(r.getLevel(), getRepeatingMessage(rc, lastRecordAllRepeatsCounter));
} else {
return null;
}
}
示例6: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
/**
*
*/
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);
}
}
}
示例7: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record)
{
if ( m_viewController != null && (record.getLevel() == Level.WARNING || record.getLevel() == Level.SEVERE) )
{
final String TOKEN_TEXT = "Text:";
final String TOKEN_DETAILS = "Error text";
final String TOKEN_STATE = "State:";
// Ignore the error reporting no EmaConfig.xml found
if ( !record.getMessage().contains("EmaConfig.xml"))
{
String[] lines = record.getMessage().split("\n");
String text = "";
for (String line : lines)
{
if (line.contains(TOKEN_TEXT))
text += line.substring(line.indexOf(TOKEN_TEXT)+TOKEN_TEXT.length()).trim() + SpeedGuide.NEWLINE;
else if (line.contains(TOKEN_DETAILS))
text += line.substring(line.indexOf(TOKEN_DETAILS)+TOKEN_DETAILS.length()).trim() + SpeedGuide.NEWLINE;
else if (line.contains(TOKEN_STATE))
text += line.substring(line.indexOf(TOKEN_STATE)+TOKEN_STATE.length()).trim() + SpeedGuide.NEWLINE;
}
// Send errors to GUI status
if (!text.isEmpty() ) {
int pos = text.lastIndexOf(SpeedGuide.NEWLINE);
if ( pos >= 0)
text = text.substring(0, pos);
m_viewController.updateStatus(text, StatusIndicator.RESPONSE_ERROR);
}
else
m_viewController.updateStatus(record.getMessage(), StatusIndicator.RESPONSE_ERROR);
}
}
super.publish(record);
}
示例8: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
/**
* Returns a string representation of the specified record.
*
* @param rec
* the rec
*
* @return a string representation of the specified record
*/
@Override
public String format(LogRecord rec) {
StringBuilder sb = new StringBuilder();
Level lvl = rec.getLevel();
sb.append(df.format(new Date(rec.getMillis())));
sb.append('[');
sb.append(rec.getLoggerName().replace("alvisnlp.", ""));
sb.append("] ");
if (colors && LEVEL_COLORS.containsKey(lvl)) {
sb.append(LEVEL_COLORS.get(lvl));
}
if ((lvl == Level.WARNING) || (lvl == Level.SEVERE)) {
sb.append(lvl);
sb.append(' ');
}
sb.append(rec.getMessage());
for (Throwable cause = rec.getThrown(); cause != null; cause = cause.getCause()) {
sb.append("\n\n### error type:\n### ");
sb.append(cause.getClass().getCanonicalName());
sb.append("\n###\n### error message:\n### ");
sb.append(cause.getMessage());
sb.append("\n###\n### stack trace:\n");
for (StackTraceElement elt : cause.getStackTrace()) {
sb.append("### ");
sb.append(elt.toString());
sb.append('\n');
}
}
sb.append('\n');
if (colors && LEVEL_COLORS.containsKey(lvl)) {
sb.append("\u001B[0m");
}
return sb.toString();
}
示例9: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public String format(LogRecord message) {
StringBuilder output = new StringBuilder();
if (message.getLevel() == Level.FINER) {
output.append(message.getSourceClassName() + ":" + message.getSourceMethodName() + ": ");
}
output.append(message.getMessage() + "\n");
return output.toString();
}
示例10: publish
import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
public void publish(LogRecord record)
{
if (record.getLevel() == Level.SEVERE)
{
String message = (new SimpleFormatter()).format(record);
_result.addError(BaseTest.this,
new AssertionFailedError(message));
}
}
示例11: 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);
}
}
示例12: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
/**
* Returns a string representation of the specified record.
*
* @param rec
* the rec
*
* @return a string representation of the specified record
*/
@Override
public String format(LogRecord rec) {
StringBuilder sb = new StringBuilder(df.format(new Date(rec.getMillis())));
sb.append('[');
sb.append(rec.getLoggerName());
sb.append("] ");
Level lvl = rec.getLevel();
if ((lvl == Level.WARNING) || (lvl == Level.SEVERE)) {
sb.append(lvl);
sb.append(' ');
}
sb.append(rec.getMessage());
for (Throwable cause = rec.getThrown(); cause != null; cause = cause.getCause()) {
sb.append("\n\n### error type:\n### ");
sb.append(cause.getClass().getCanonicalName());
sb.append("\n###\n### error message:\n### ");
sb.append(cause.getMessage());
sb.append("\n###\n### stack trace:\n");
for (StackTraceElement elt : cause.getStackTrace()) {
sb.append("### ");
sb.append(elt.toString());
sb.append('\n');
}
}
sb.append("\n");
return sb.toString();
}
示例13: format
import java.util.logging.LogRecord; //導入方法依賴的package包/類
public String format(LogRecord record)
{
StringBuilder stringbuilder = new StringBuilder();
stringbuilder.append("[");
stringbuilder.append("Shaders").append("]");
if (record.getLevel() != SMCLog.SMCINFO)
{
stringbuilder.append("[").append((Object)record.getLevel()).append("]");
}
stringbuilder.append(" ");
stringbuilder.append(record.getMessage()).append("\n");
return stringbuilder.toString();
}
示例14: print
import java.util.logging.LogRecord; //導入方法依賴的package包/類
private void print(StringBuilder sb, LogRecord record, Set<Throwable> beenThere) {
String message = formatMessage(record);
if (message != null && message.indexOf('\n') != -1 && record.getThrown() == null) {
// multi line messages print witout any wrappings
sb.append(message);
if (message.charAt(message.length() - 1) != '\n') {
sb.append(lineSeparator);
}
return;
}
if ("stderr".equals(record.getLoggerName()) && record.getLevel() == Level.INFO) {
// NOI18N
// do not prefix stderr logging...
sb.append(message);
return;
}
sb.append(record.getLevel().getName());
addLoggerName(sb, record);
if (message != null) {
sb.append(": ");
sb.append(message);
}
sb.append(lineSeparator);
if (record.getThrown() != null && record.getLevel().intValue() != 1973) {
// 1973 signals ErrorManager.USER
try {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
// All other kinds of throwables we check for a stack trace.
printStackTrace(record.getThrown(), pw);
pw.close();
sb.append(sw.toString());
} catch (Exception ex) {
}
LogRecord[] arr = extractDelegates(sb, record.getThrown(), beenThere);
if (arr != null) {
for (LogRecord r : arr) {
print(sb, r, beenThere);
}
}
specialProcessing(sb, record.getThrown(), beenThere);
}
}
示例15: createAllRepeatsRecord
import java.util.logging.LogRecord; //導入方法依賴的package包/類
private LogRecord createAllRepeatsRecord(LogRecord r, long allRc) {
return new LogRecord(r.getLevel(), getAllRepeatsMessage(allRc));
}