當前位置: 首頁>>代碼示例>>Java>>正文


Java LogService.LOG_INFO屬性代碼示例

本文整理匯總了Java中org.osgi.service.log.LogService.LOG_INFO屬性的典型用法代碼示例。如果您正苦於以下問題:Java LogService.LOG_INFO屬性的具體用法?Java LogService.LOG_INFO怎麽用?Java LogService.LOG_INFO使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.osgi.service.log.LogService的用法示例。


在下文中一共展示了LogService.LOG_INFO屬性的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);
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:23,代碼來源:TestLogService.java

示例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;
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:17,代碼來源:OsgiLogHandler.java

示例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;
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:20,代碼來源:ConsoleLogFormatter.java

示例4: formatException

private StringBuilder formatException(LogEntry entry, StringBuilder out) {
    Throwable t = entry.getException();
    if (t != null) {
        if (entry.getLevel() == LogService.LOG_INFO) {
            out.append(": ");
            String msg = t.getMessage();
            if (msg != null) {
                formatString(msg, out);
            } else {
                out.append(t.getClass().getName());
            }
        } else {
            Writer buf = new StringWriter();
            t.printStackTrace(new PrintWriter(buf));
            formatString("\n" + buf, out);
        }
    }
    return out;
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:19,代碼來源:ConsoleLogFormatter.java

示例5: 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));
    }
}
 
開發者ID:vespa-engine,項目名稱:vespa,代碼行數:16,代碼來源:OsgiLogHandlerTestCase.java

示例6: 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" );
}
 
開發者ID:mcculls,項目名稱:osgi-in-action,代碼行數:27,代碼來源:MockLogService.java

示例7: 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);
}
 
開發者ID:wso2,項目名稱:wso2-axis2,代碼行數:17,代碼來源:Logger.java

示例8: 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;
	}
}
 
開發者ID:ibcn-cloudlet,項目名稱:androsgi,代碼行數:17,代碼來源:AndroidLogService.java

示例9: 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());
        }
    }
}
 
開發者ID:gvSIGAssociation,項目名稱:gvnix1,代碼行數:40,代碼來源:JdkDelegatingLogListener.java

示例10: 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;
  }
}
 
開發者ID:everit-org,項目名稱:ecm-extender-ri,代碼行數:14,代碼來源:JavaUtilLogService.java

示例11: 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;
}
	}
 
開發者ID:Neulinet,項目名稱:Zoo,代碼行數:11,代碼來源:OSGILogListener.java

示例12: 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;
}
	}
 
開發者ID:andrey-desman,項目名稱:openhab-hdl,代碼行數:10,代碼來源:OSGILogListener.java

示例13: 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;
	}
}
 
開發者ID:osgi,項目名稱:osgi.iot.contest.sdk,代碼行數:12,代碼來源:LogTracker.java

示例14: 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);
    }
}
 
開發者ID:cohorte,項目名稱:cohorte-herald,代碼行數:48,代碼來源:MulticastHandler.java

示例15: createMessagePart

private static String createMessagePart(int logLevel, StackTraceElement stackTraceElement, String message) {
    if (logLevel == LogService.LOG_INFO) {
        return message;
    }
    if (stackTraceElement != null) {
        return message + " ;; (" + "{" + Thread.currentThread().getName() + "} " + stackTraceElement.getClassName() + "."
                + stackTraceElement.getMethodName() + "#"
                + stackTraceElement.getLineNumber() + ") ";
    } else {
        return message;
    }
}
 
開發者ID:Ericsson-LMF,項目名稱:IoT-Gateway,代碼行數:12,代碼來源:OSGiLogger.java


注:本文中的org.osgi.service.log.LogService.LOG_INFO屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。