Java Code Examples for org.osgi.service.log.LogService#LOG_DEBUG
The following examples show how to use
org.osgi.service.log.LogService#LOG_DEBUG .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoggerDelegate.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Override public void log(Object context, int level, String message, Throwable exception) { // Oddly LogService#LOG_xxx are deprecated in favour of LogLevel enum, but // the LogLevel enum does not provide integer mappings. switch (level) { case LogService.LOG_ERROR: logger.error(message, exception); break; case LogService.LOG_WARNING: logger.warn(message, exception); break; case LogService.LOG_INFO: logger.info(message, exception); break; case LogService.LOG_DEBUG: logger.debug(message, exception); break; default: logger.debug(message, exception); break; } }
Example 2
Source File: LoggerDelegate.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Override public boolean isLoggable(int level) { // Oddly LogService#LOG_xxx are deprecated in favour of LogLevel enum, but // the LogLevel enum does not provide integer mappings. switch (level) { case LogService.LOG_ERROR: return isErrorEnabled(); case LogService.LOG_WARNING: return isWarnEnabled(); case LogService.LOG_INFO: return isInfoEnabled(); case LogService.LOG_DEBUG: return isDebugEnabled(); default: return false; } }
Example 3
Source File: OsgiLogHandler.java From vespa with Apache License 2.0 | 6 votes |
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; }
Example 4
Source File: ConsoleLogFormatter.java From vespa with Apache License 2.0 | 6 votes |
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; }
Example 5
Source File: OsgiLogHandlerTestCase.java From vespa with Apache License 2.0 | 6 votes |
@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)); } }
Example 6
Source File: LogUtil.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Converts a string representing a log severity level to an int. * * @param level * The string to convert. * @param def * Default value to use if the string is not recognized * as a log level. * @return the log level, or the default value if the string can not * be recognized. */ static public int toLevel(String level, int def) { if (level==null) { return def; } level = level.trim(); if (level.equalsIgnoreCase("INFO")) { return LogService.LOG_INFO; } else if (level.equalsIgnoreCase("DEBUG")) { return LogService.LOG_DEBUG; } else if (level.equalsIgnoreCase("WARNING")) { return LogService.LOG_WARNING; } else if (level.equalsIgnoreCase("ERROR")) { return LogService.LOG_ERROR; } else if (level.equalsIgnoreCase("DEFAULT")) { return 0; } return def; }
Example 7
Source File: LogFrameworkListener.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * The service event callback method inserts all service events into the * log. * * Event of types REGISTERED, UNREGISTERED are assigned the log * level info. * * Events of type MODIFIED are assigned the log level DEBUG. * * @param se * the service event that has occurred. */ public void serviceChanged(ServiceEvent se) { ServiceReference<?> sr = se.getServiceReference(); Bundle bundle = sr.getBundle(); String msg = null; int level = LogService.LOG_INFO; switch (se.getType()) { case ServiceEvent.REGISTERED: msg = "ServiceEvent REGISTERED"; break; case ServiceEvent.UNREGISTERING: msg = "ServiceEvent UNREGISTERING"; break; case ServiceEvent.MODIFIED: msg = "ServiceEvent MODIFIED"; level = LogService.LOG_DEBUG; break; } lrsf.log(new LogEntryImpl(bundle, sr, level, msg)); }
Example 8
Source File: LogUtil.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Converts from a numeric log severity level to a left justified * string of at least the given length. * * @param level * is the log severity level. * @param length * the minimum length of the resulting string. * @return left justified string representation of a numeric log level. */ static public String fromLevel(int level, int length) { final StringBuffer sb = new StringBuffer(length > 7 ? length : 7); switch (level) { case LogService.LOG_INFO: sb.append("info"); break; case LogService.LOG_DEBUG: sb.append("debug"); break; case LogService.LOG_WARNING: sb.append("Warning"); break; case LogService.LOG_ERROR: sb.append("ERROR"); break; case 0: sb.append("DEFAULT"); break; default: sb.append("["); sb.append(level); sb.append("]"); } for (int i = sb.length(); i < length; i++) { sb.append(" "); } return sb.toString(); }