use of org.osgi.service.log.LogEntry in project sling by apache.
the class LogSupportTest method testInfoLogger.
@Test
public void testInfoLogger() throws Exception {
LogEntry le = new LogEntryImpl(bundle, null, LogService.LOG_INFO, "my-info-message", null);
logSupport.fireLogEvent(le);
Mockito.verify(testLogger).info("my-info-message", (Throwable) null);
}
use of org.osgi.service.log.LogEntry in project felix by apache.
the class LogServlet method renderJSON.
private final void renderJSON(final PrintWriter pw, int minLogLevel, boolean traces) throws IOException {
// create status line
final LogReaderService logReaderService = (LogReaderService) this.getService(LogReaderService.class.getName());
JSONWriter jw = new JSONWriter(pw);
jw.object();
// $NON-NLS-1$
jw.key("status");
jw.value(logReaderService == null ? Boolean.FALSE : Boolean.TRUE);
// $NON-NLS-1$
jw.key("data");
jw.array();
if (logReaderService != null) {
int index = 0;
for (Enumeration logEntries = logReaderService.getLog(); logEntries.hasMoreElements() && index < MAX_LOGS; ) {
LogEntry nextLog = (LogEntry) logEntries.nextElement();
if (nextLog.getLevel() <= minLogLevel) {
logJson(jw, nextLog, index++, traces);
}
}
}
jw.endArray();
jw.endObject();
}
use of org.osgi.service.log.LogEntry in project felix by apache.
the class TestManifestLoggerInfo method getMessages.
private List<String> getMessages(Enumeration<LogEntry> log2) {
List<String> list = new ArrayList<String>();
while (log2.hasMoreElements()) {
LogEntry entry = (LogEntry) log2.nextElement();
list.add(entry.getMessage());
}
return list;
}
use of org.osgi.service.log.LogEntry in project felix by apache.
the class Logger method sendOldLog.
// ///////////////////////////////
// LogerMBean Interface //
// ///////////////////////////////
public void sendOldLog() {
System.out.println("[remoteLogger.Logger] send old log");
Enumeration oldLog = this.lrs.getLog();
Vector invert = new Vector();
while (oldLog.hasMoreElements()) {
LogEntry le = (LogEntry) (oldLog.nextElement());
invert.insertElementAt(le, 0);
}
for (int i = 0; i < invert.size(); i++) {
logged((LogEntry) invert.elementAt(i), true);
}
}
use of org.osgi.service.log.LogEntry in project felix by apache.
the class Log method serviceChanged.
/**
* Called when a service event occurs.
* @param event the event that occured
*/
public void serviceChanged(final ServiceEvent event) {
int eventType = event.getType();
String message = null;
for (int i = 0; message == null && i < SERVICE_EVENT_MESSAGES.length; ++i) {
if (eventType >> i == 1) {
message = SERVICE_EVENT_MESSAGES[i];
}
}
LogEntry entry = new LogEntryImpl(event.getServiceReference().getBundle(), event.getServiceReference(), (eventType == ServiceEvent.MODIFIED) ? LogService.LOG_DEBUG : LogService.LOG_INFO, message, null);
addEntry(entry);
}
Aggregations