本文整理匯總了Java中org.osgi.service.log.LogService類的典型用法代碼示例。如果您正苦於以下問題:Java LogService類的具體用法?Java LogService怎麽用?Java LogService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LogService類屬於org.osgi.service.log包,在下文中一共展示了LogService類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setAutoCommit
import org.osgi.service.log.LogService; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public void setAutoCommit(boolean arg0) throws SQLException {
for (;;) {
try {
wrappedConnection.setAutoCommit(arg0);
break;
} catch (SQLException ex) {
Activator.log(LogService.LOG_DEBUG,"setAutoCommit:" + ex.getMessage() + ", "+ ex.getCause());
if ((ex.getErrorCode() == SQLiteErrorCode.SQLITE_LOCKED.code)
|| (ex.getMessage().equals("database is locked"))) {
continue;
}
throw ex;
}
}
}
示例2: PluginResolveContext
import org.osgi.service.log.LogService; //導入依賴的package包/類
PluginResolveContext(BundleContext bundleContext, ResolveRequest request, LogService log) throws IOException {
this.bundleContext = bundleContext;
this.log = log;
this.initialResource = new ResourceImpl();
request.getRequirements().stream().forEach(this.initialResource::addRequirement);
this.initialResource.addCapability(createIdentityCap(this.initialResource, request.getName()));
this.initialResource.addCapability(createInitialMarkerCapability(this.initialResource));
BasicRegistry registry = new BasicRegistry().put(URLConnector.class, new JarURLConnector());
for (URI indexUri : request.getIndexes()) {
//URI cachedIndexUri = getCacheIndexURI(indexUri);
Map<String,String> repoProps = new HashMap<>();
repoProps.put("locations", indexUri.toString());
FixedIndexedRepo repo = new FixedIndexedRepo();
repo.setRegistry(registry);
repo.setProperties(repoProps);
this.repositories.put(indexUri, repo);
}
}
示例3: activate
import org.osgi.service.log.LogService; //導入依賴的package包/類
@Activate
void activate(BundleContext context) {
this.context = context;
context.addFrameworkListener(this.frameworkListener);
context.addBundleListener(this.bundleListener);
this.processorThread = new Thread(() -> {
this.log.log(LogService.LOG_INFO, "Deployment Installer thread starting");
debug("Deployment Install thread starting");
while (!Thread.interrupted()) {
try {
Runnable job = waitForJob();
job.run();
} catch (InterruptedException e) {
debug("Deployment Install thread interrupted");
this.log.log(LogService.LOG_INFO, "Deployment Installer thread interrupted");
break;
} catch (Exception e) {
this.log.log(LogService.LOG_ERROR, "Error processing job on Deployment Installer thread", e);
}
}
debug("Deployment Install thread terminated.");
this.log.log(LogService.LOG_INFO, "Deployment Installer thread terminated");
});
this.processorThread.start();
}
示例4: log
import org.osgi.service.log.LogService; //導入依賴的package包/類
@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);
}
示例5: toServiceLevel
import org.osgi.service.log.LogService; //導入依賴的package包/類
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;
}
示例6: formatLevel
import org.osgi.service.log.LogService; //導入依賴的package包/類
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;
}
示例7: formatException
import org.osgi.service.log.LogService; //導入依賴的package包/類
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;
}
示例8: requireThatLogServiceIsRegistered
import org.osgi.service.log.LogService; //導入依賴的package包/類
@Test
public void requireThatLogServiceIsRegistered() throws BundleException, InterruptedException {
OsgiFramework osgi = TestDriver.newOsgiFramework();
osgi.start();
ServiceTracker<?,?> logs = newTracker(osgi, LogService.class);
ServiceTracker<?,?> logReaders = newTracker(osgi, LogReaderService.class);
assertEquals(1, logs.getTrackingCount());
assertEquals(1, logReaders.getTrackingCount());
OsgiLogService service = new OsgiLogService();
service.start(osgi.bundleContext());
assertEquals(2, logs.getTrackingCount());
assertEquals(2, logReaders.getTrackingCount());
osgi.stop();
}
示例9: requireThatCustomLogLevelsAreConverted
import org.osgi.service.log.LogService; //導入依賴的package包/類
@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));
}
}
示例10: addingBundle
import org.osgi.service.log.LogService; //導入依賴的package包/類
@Override
public Bundle addingBundle(final Bundle bundle, final BundleEvent event) {
Collection<BundleRequirement> wiredRequirements = resolveWiredRequirements(bundle);
if (wiredRequirements.size() == 0) {
return null;
}
List<ComponentContainerInstance<?>> containers;
try {
containers = addBundleRequirements(bundle, wiredRequirements);
} catch (RuntimeException e) {
logService.log(LogService.LOG_ERROR, "Error during processing requirements of bundle: "
+ bundle.getSymbolicName() + ":" + bundle.getVersion(), e);
return null;
}
activeComponentContainers.put(bundle, containers);
return bundle;
}
示例11: precheckSmtp
import org.osgi.service.log.LogService; //導入依賴的package包/類
public SmtpProperties precheckSmtp(SmtpProperties smtp) {
if (smtp.getHost() == null && smtpServerName != null){
smtp.setHost(smtpServerName);
smtp.setDefaultSender(this.from);
smtp.setPort(this.useSmtpPort);
smtp.setPassword(this.smtpUserPassword);
smtp.setUserName(this.smtpUserName);
smtp.setUseAuthentication(this.useSmtpAuth);
smtp.setUseSSL(this.useSSL);
}
logService.log(LogService.LOG_INFO, String.format("EmailSender configured with serverName = %s, serverPort = %d, from = %s, logOnly = %s",
smtp.getHost(), smtp.getPort(), smtp.getFrom(), logOnly));
return smtp;
}
示例12: isEventTypeAllowed
import org.osgi.service.log.LogService; //導入依賴的package包/類
private boolean isEventTypeAllowed(final UUID kbAccountId, final UUID kbTenantId, final ExtBusEventType eventType)
{
final EmailNotificationsConfiguration registeredEventType;
final EmailNotificationConfiguration configuration = emailNotificationConfigurationHandler.getConfigurable(kbTenantId);
if (configuration.getEventTypes().contains(eventType.toString()))
{
return true;
}
try {
registeredEventType = this.dao.getEventTypePerAccount(kbAccountId,kbTenantId,eventType);
} catch (SQLException e) {
logService.log(LogService.LOG_ERROR, String.format("Error retrieving email notification event registry: %s",e.getMessage()));
return false;
}
if (registeredEventType == null) {
logService.log(LogService.LOG_WARNING, String.format("Registration of event %s is not available for account %s.",eventType.toString(),kbAccountId));
return false;
}
return true;
}
示例13: trainRecommenders
import org.osgi.service.log.LogService; //導入依賴的package包/類
private void trainRecommenders(DataSet train) {
Parallel.For(Arrays.asList(recommenders), r -> {
try {
r.setDataSourceId(this.getId() + ":" + this.getDataSourceId());
r.setDataSet(train);
r.train();
} catch (Exception e) {
e.printStackTrace();
if (this.logger != null) {
this.logger.log(LogService.LOG_ERROR, String.format("The training of recommender %s failed. Exception message: %s", r.getId(), e.getMessage()));
setInfo(String.format("The training of recommender %s failed. Exception message: %s", r.getId(), e.getMessage()));
}
}
});
}
示例14: createPage
import org.osgi.service.log.LogService; //導入依賴的package包/類
@Override
public void createPage() {
// create the page via DI using the OSGi service context
try {
IPreferencePage page = ContextInjectionFactory.make(this.pageClass, this.context);
setPage(page);
if (getLabelImage() != null) {
getPage().setImageDescriptor(getImageDescriptor());
}
getPage().setTitle(getLabelText());
((PreferencePage) getPage()).setPreferenceStore(this.store);
}
catch (Exception e) {
if (this.logger != null) {
this.logger.log(
LogService.LOG_ERROR,
"Error on creating instance of " + this.pageClass.getName(),
e);
}
}
}
示例15: toMessageLine
import org.osgi.service.log.LogService; //導入依賴的package包/類
/**
* 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" );
}