本文整理匯總了Java中org.osgi.service.log.LogService.LOG_ERROR屬性的典型用法代碼示例。如果您正苦於以下問題:Java LogService.LOG_ERROR屬性的具體用法?Java LogService.LOG_ERROR怎麽用?Java LogService.LOG_ERROR使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.osgi.service.log.LogService
的用法示例。
在下文中一共展示了LogService.LOG_ERROR屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: log
@SuppressWarnings("rawtypes")
@Override
public void log(ServiceReference sr, int level, String message, Throwable exception) {
String levelStr;
switch (level) {
case LogService.LOG_DEBUG:
levelStr = "DEBUG";
break;
case LogService.LOG_INFO:
levelStr = "INFO";
break;
case LogService.LOG_WARNING:
levelStr = "WARNING";
break;
case LogService.LOG_ERROR:
levelStr = "ERROR";
break;
default:
levelStr = "UNKNOWN";
}
String formatted = String.format("%s: %s %s", levelStr, message, exception != null ? exception : "");
this.logged.add(formatted);
}
示例2: toServiceLevel
public static int toServiceLevel(Level level) {
int val = level.intValue();
if (val >= Level.SEVERE.intValue()) {
return LogService.LOG_ERROR;
}
if (val >= Level.WARNING.intValue()) {
return LogService.LOG_WARNING;
}
if (val >= Level.INFO.intValue()) {
return LogService.LOG_INFO;
}
// Level.CONFIG
// Level.FINE
// Level.FINER
// Level.FINEST
return LogService.LOG_DEBUG;
}
示例3: formatLevel
private StringBuilder formatLevel(LogEntry entry, StringBuilder out) {
switch (entry.getLevel()) {
case LogService.LOG_ERROR:
out.append("error");
break;
case LogService.LOG_WARNING:
out.append("warning");
break;
case LogService.LOG_INFO:
out.append("info");
break;
case LogService.LOG_DEBUG:
out.append("debug");
break;
default:
out.append("unknown");
break;
}
return out;
}
示例4: requireThatCustomLogLevelsAreConverted
@Test
public void requireThatCustomLogLevelsAreConverted() {
for (int i = Level.ALL.intValue() - 69; i < Level.OFF.intValue() + 69; ++i) {
int expectedLevel;
if (i >= Level.SEVERE.intValue()) {
expectedLevel = LogService.LOG_ERROR;
} else if (i >= Level.WARNING.intValue()) {
expectedLevel = LogService.LOG_WARNING;
} else if (i >= Level.INFO.intValue()) {
expectedLevel = LogService.LOG_INFO;
} else {
expectedLevel = LogService.LOG_DEBUG;
}
assertLogLevel(expectedLevel, new MyLogLevel(i));
}
}
示例5: toMessageLine
/**
* Helper method to format log level and log message exactly the same as the
* <code>ConfigurationManager.log()</code> does.
*/
public static String toMessageLine( int level, String message )
{
String messageLine;
switch ( level )
{
case LogService.LOG_INFO:
messageLine = "*INFO *";
break;
case LogService.LOG_WARNING:
messageLine = "*WARN *";
break;
case LogService.LOG_ERROR:
messageLine = "*ERROR*";
break;
case LogService.LOG_DEBUG:
default:
messageLine = "*DEBUG*";
}
return messageLine + " " + message + System.getProperty( "line.separator" );
}
示例6: print
private void print(int i, String s) {
switch(i){
case LogService.LOG_ERROR:
System.out.print("[ERROR] ");
break;
case LogService.LOG_INFO:
System.out.print("[INFO] ");
break;
case LogService.LOG_WARNING:
System.out.print("[WARNING]");
break;
case LogService.LOG_DEBUG:
System.out.print("[DEBUG] ");
break;
}
System.out.println(" : " + s);
}
示例7: log
@Override
public void log(int level, String message) {
switch(level){
case LogService.LOG_DEBUG:
Log.d(TAG, message);
break;
case LogService.LOG_ERROR:
Log.e(TAG, message);
break;
case LogService.LOG_INFO:
Log.i(TAG, message);
break;
case LogService.LOG_WARNING:
Log.w(TAG, message);
break;
}
}
示例8: logNow
private void logNow(final LogEntry entry, final boolean removeDoNotLogTag) {
final int osgiLevel = entry.getLevel();
Level jdkLevel = Level.FINEST;
// Convert the OSGi level into a JDK logger level
if (osgiLevel == LogService.LOG_DEBUG) {
jdkLevel = Level.FINE;
}
else if (osgiLevel == LogService.LOG_INFO) {
jdkLevel = Level.INFO;
}
else if (osgiLevel == LogService.LOG_WARNING) {
jdkLevel = Level.WARNING;
}
else if (osgiLevel == LogService.LOG_ERROR) {
jdkLevel = Level.SEVERE;
}
if (jdkLevel.intValue() <= Level.INFO.intValue()) {
// Not very important message, so just flash it if possible and
// we're in development mode
if (isDevelopmentMode()) {
flash(jdkLevel, buildMessage(entry), MY_SLOT);
// Immediately clear it once the timeout has been reached
flash(jdkLevel, "", MY_SLOT);
}
}
else {
// Important log message, so log it via JDK
if (removeDoNotLogTag) {
LOGGER.log(
jdkLevel,
buildMessage(entry)
+ cleanThrowable(entry.getException()));
}
else {
LOGGER.log(jdkLevel, buildMessage(entry), entry.getException());
}
}
}
示例9: convertLogServiceLevelToJavaLoggerLevel
private static Level convertLogServiceLevelToJavaLoggerLevel(final int logServiceLevel) {
switch (logServiceLevel) {
case LogService.LOG_DEBUG:
return Level.FINE;
case LogService.LOG_ERROR:
return Level.SEVERE;
case LogService.LOG_INFO:
return Level.INFO;
case LogService.LOG_WARNING:
return Level.WARNING;
default:
return Level.INFO;
}
}
示例10: logged
public void logged(LogEntry entry) {
Logger logger = LoggerFactory.getLogger("OSGi");
String markerName = entry.getBundle() == null ? "unknownBundle" : entry.getBundle().getSymbolicName();
Marker marker = MarkerFactory.getMarker(markerName);
switch(entry.getLevel()) {
case LogService.LOG_DEBUG: logger.debug(marker, entry.getMessage(), entry.getException()); break;
case LogService.LOG_INFO: logger.info(marker, entry.getMessage(), entry.getException()); break;
case LogService.LOG_WARNING: logger.warn(marker, entry.getMessage(), entry.getException()); break;
case LogService.LOG_ERROR: logger.error(marker, entry.getMessage(), entry.getException()); break;
}
}
示例11: logged
public void logged(LogEntry entry) {
Logger logger = LoggerFactory.getLogger("OSGi");
Marker marker = MarkerFactory.getMarker(entry.getBundle().getSymbolicName());
switch(entry.getLevel()) {
case LogService.LOG_DEBUG: logger.debug(marker, entry.getMessage(), entry.getException()); break;
case LogService.LOG_INFO: logger.info(marker, entry.getMessage(), entry.getException()); break;
case LogService.LOG_WARNING: logger.warn(marker, entry.getMessage(), entry.getException()); break;
case LogService.LOG_ERROR: logger.error(marker, entry.getMessage(), entry.getException()); break;
}
}
示例12: getLevel
private Level getLevel(int level) {
switch (level) {
case LogService.LOG_ERROR:
return Level.error;
case LogService.LOG_WARNING:
return Level.warning;
case LogService.LOG_INFO:
return Level.info;
default:
return Level.debug;
}
}
示例13: log
/**
* Logs an entry if a logger is present, else prints on the error output
*
* @param aLevel
* Log level
* @param aMessage
* Log entry
* @param aThrowable
* Associated error
*/
private void log(final int aLevel, final String aMessage,
final Throwable aThrowable) {
if (pLogger != null) {
// Use the log service
pLogger.log(aLevel, aMessage, aThrowable);
} else {
// Use a Java logger
// Convert the level
Level level;
switch (aLevel) {
case LogService.LOG_ERROR:
level = Level.SEVERE;
break;
case LogService.LOG_WARNING:
level = Level.WARNING;
break;
case LogService.LOG_INFO:
level = Level.INFO;
break;
case LogService.LOG_DEBUG:
default:
level = Level.FINE;
break;
}
// Log a record
final LogRecord record = new LogRecord(level, aMessage);
record.setThrown(aThrowable);
Logger.getLogger(BUNDLE_NAME).log(record);
}
}
示例14: getLogLevelString
private static String getLogLevelString(int logLevel) {
switch (logLevel) {
case LogService.LOG_ERROR:
return "ERROR";
case LogService.LOG_WARNING:
return "WARNING";
case LogService.LOG_DEBUG:
return "DEBUG";
case LogService.LOG_INFO:
return "INFO";
default:
return "UNKOWN";
}
}
示例15: logged
@Override
public void logged(final LogEntry logEntry) {
Bundle bundle = logEntry.getBundle();
Logger logger = getLogger(bundle);
int level = logEntry.getLevel();
String message = logEntry.getMessage();
Throwable exception = logEntry.getException();
switch (level) {
case LogService.LOG_DEBUG:
logger.debug(message, exception);
break;
case LogService.LOG_INFO:
logger.info(message, exception);
break;
case LogService.LOG_WARNING:
logger.warn(message, exception);
break;
case LogService.LOG_ERROR:
logger.error(message, exception);
break;
default:
logger.warn("[unknown level (" + level + ")] " + message, exception);
break;
}
}