use of org.osgi.service.log.LogEntry in project felix by apache.
the class LogNodeEnumeration method nextElement.
/**
* Returns the current element and moves onto the next element.
* @return the current element
*/
public Object nextElement() {
LogEntry result = null;
if (m_next == m_last) {
result = m_next.getEntry();
m_next = null;
} else if (m_next != null) {
result = m_next.getEntry();
m_next = m_next.getNextNode();
}
return result;
}
use of org.osgi.service.log.LogEntry in project felix by apache.
the class LogCommandImpl method execute.
public void execute(String line, PrintStream out, PrintStream err) {
LogOptions options = new LogOptions(line);
ServiceReference ref = m_bundleContext.getServiceReference(LogReaderService.class.getName());
if (ref != null) {
LogReaderService service = (LogReaderService) m_bundleContext.getService(ref);
Enumeration entries = service.getLog();
int index = 0;
while (entries.hasMoreElements() && (options.getMaxNumberOfLogs() < 0 | index < options.getMaxNumberOfLogs())) {
LogEntry entry = (LogEntry) entries.nextElement();
if (entry.getLevel() <= options.getMinLevel()) {
display(entry, out);
index++;
}
}
} else {
out.println("No LogReaderService available");
}
}
use of org.osgi.service.log.LogEntry in project bnd by bndtools.
the class TestingLog method check.
public boolean check(String... patterns) {
if (entries.isEmpty())
return true;
int n = entries.size();
for (LogEntry le : entries) {
for (String pattern : patterns) {
if (le.getMessage().contains(pattern))
n--;
else
System.out.println(le);
}
}
entries.clear();
return n != 0;
}
use of org.osgi.service.log.LogEntry in project rt.equinox.framework by eclipse.
the class OrderedExecutor method logPrivileged.
void logPrivileged(Bundle bundle, String name, StackTraceElement stackTraceElement, Object context, LogLevel logLevelEnum, int level, String message, Throwable exception) {
LogEntry logEntry = new ExtendedLogEntryImpl(bundle, name, stackTraceElement, context, logLevelEnum, level, message, exception);
storeEntry(logEntry);
ArrayMap<LogListener, Object[]> listenersCopy;
listenersLock.readLock().lock();
try {
listenersCopy = listeners;
} finally {
listenersLock.readLock().unlock();
}
try {
if (incrementNestedCount() >= MAX_RECURSIONS)
return;
int size = listenersCopy.size();
for (int i = 0; i < size; i++) {
Object[] listenerObjects = listenersCopy.getValue(i);
LogFilter filter = (LogFilter) listenerObjects[0];
if (safeIsLoggable(filter, bundle, name, level)) {
LogListener listener = listenersCopy.getKey(i);
OrderedTaskQueue orderedTaskQueue = (OrderedTaskQueue) listenerObjects[1];
if (orderedTaskQueue != null) {
orderedTaskQueue.execute(new LogTask(logEntry, listener), size);
} else {
// log synchronously
safeLogged(listener, logEntry);
}
}
}
} finally {
decrementNestedCount();
}
}
use of org.osgi.service.log.LogEntry in project rt.equinox.framework by eclipse.
the class ExtendedLogReaderServiceTest method testSynchronousLogListener.
public void testSynchronousLogListener() throws Exception {
final Thread loggerThread = Thread.currentThread();
called = false;
LogListener listener = new SynchronousLogListener() {
public void logged(LogEntry entry) {
assertTrue(Thread.currentThread() == loggerThread);
called = true;
}
};
reader.addLogListener(listener);
log.log(LogService.LOG_INFO, "info");
assertTrue(called);
}
Aggregations