use of org.ops4j.pax.logging.spi.PaxLoggingEvent in project karaf by apache.
the class LogServiceImpl method getLastException.
@Override
public PaxLoggingEvent getLastException(String logger) {
PaxLoggingEvent throwableEvent = null;
Iterable<PaxLoggingEvent> le = getEvents();
for (PaxLoggingEvent event : le) {
// then save this exception and continue iterating from oldest to newest
if ((event.getThrowableStrRep() != null) && (logger != null) && (checkIfFromRequestedLog(event, logger))) {
throwableEvent = event;
// Do not break, as we iterate from the oldest to the newest event
} else if ((event.getThrowableStrRep() != null) && (logger == null)) {
// now check if there has been no log passed in, and if this is an exception
// then save this exception and continue iterating from oldest to newest
throwableEvent = event;
}
}
return throwableEvent;
}
use of org.ops4j.pax.logging.spi.PaxLoggingEvent in project cytoscape-impl by cytoscape.
the class CyActivator method start.
public void start(final BundleContext bc) {
final CySwingApplication cySwingApplicationRef = getService(bc, CySwingApplication.class);
final TaskManager taskManagerRef = getService(bc, TaskManager.class);
final Map<String, String> logViewerConfig = ezMap("baseHTMLPath", "/consoledialogbase.html", "colorParityTrue", "ffffff", "colorParityFalse", "f9f9f9", "entryTemplate", " <html> <body bgcolor=\"#%s\"> <table border=0 width=\"100%%\" cellspacing=5> <tr> <td width=\"0%%\"><img src=\"%s\"></td> <td><h3>%s</h3></td> </tr> <tr> <td></td> <td><font size=\"-2\" color=\"#555555\">%s</font></td> </tr> </table> </body> </html>", "DEBUG", "console-debug.png", "ERROR", "console-error.png", "FATAL", "console-error.png", "INFO", "console-info.png", "TRACE", "console-debug.png", "WARN", "console-warn.png");
final UserMessagesDialog userMessagesDialog = new UserMessagesDialog(cySwingApplicationRef, logViewerConfig);
registerService(bc, new AbstractTaskFactory() {
public TaskIterator createTaskIterator() {
return new TaskIterator(new Task() {
public void cancel() {
}
public void run(TaskMonitor monitor) {
userMessagesDialog.open();
}
});
}
}, TaskFactory.class, ezProps(PREFERRED_MENU, "Help", TITLE, "User Messages...", MENU_GRAVITY, "3.0"));
final CyStatusBar statusBar = new CyStatusBar(cySwingApplicationRef, "/logConsole.png", userMessagesDialog, ezMap("DEBUG", "/status-bar-debug.png", "ERROR", "/status-bar-error.png", "FATAL", "/status-bar-error.png", "INFO", "/status-bar-info.png", "TRACE", "/status-bar-debug.png", "WARN", "/status-bar-warn.png"));
final ExecutorService executor = Executors.newCachedThreadPool(new LowPriorityDaemonThreadFactory());
final LinkedBlockingQueue<PaxLoggingEvent> userMessagesQueue = new LinkedBlockingQueue<PaxLoggingEvent>();
executor.submit(new UserMessagesProcesser(userMessagesQueue, statusBar, userMessagesDialog));
registerService(bc, new AppenderToQueue(userMessagesQueue), PaxAppender.class, ezProps("org.ops4j.pax.logging.appender.name", "OrgCytoscapeLogSwingUserMessagesAppender"));
final ConsoleDialog consoleDialog = new ConsoleDialog(taskManagerRef, cySwingApplicationRef, logViewerConfig);
final LinkedBlockingQueue<PaxLoggingEvent> allLogMessagesQueue = new LinkedBlockingQueue<PaxLoggingEvent>();
executor.submit(new AllLogMessagesProcesser(allLogMessagesQueue, consoleDialog));
registerService(bc, new AppenderToQueue(allLogMessagesQueue), PaxAppender.class, ezProps("org.ops4j.pax.logging.appender.name", "OrgCytoscapeLogSwingAllLogMessagesAppender"));
registerService(bc, new AbstractTaskFactory() {
public TaskIterator createTaskIterator() {
return new TaskIterator(new Task() {
public void cancel() {
}
public void run(TaskMonitor monitor) {
consoleDialog.open();
}
});
}
}, TaskFactory.class, ezProps(PREFERRED_MENU, "Help", TITLE, "Developer's Log Console...", MENU_GRAVITY, "4.0"));
}
use of org.ops4j.pax.logging.spi.PaxLoggingEvent in project cytoscape-impl by cytoscape.
the class QueueProcesser method run.
public void run() {
while (true) {
PaxLoggingEvent event = null;
try {
event = queue.take();
} catch (InterruptedException e) {
break;
}
processEvent(event);
}
}
use of org.ops4j.pax.logging.spi.PaxLoggingEvent in project fabric8 by jboss-fuse.
the class LogQuery method getLogEventList.
public LogResults getLogEventList(int count, Predicate<PaxLoggingEvent> predicate) {
LogResults answer = new LogResults();
answer.setHost(getHostName());
long from = Long.MAX_VALUE;
long to = Long.MIN_VALUE;
if (appender != null) {
LruList events = appender.getEvents();
if (events != null) {
Iterable<PaxLoggingEvent> iterable = events.getElements();
if (iterable != null) {
int matched = 0;
for (PaxLoggingEvent event : iterable) {
if (event != null) {
long timestamp = event.getTimeStamp();
if (timestamp > to) {
to = timestamp;
}
if (timestamp < from) {
from = timestamp;
}
if (predicate == null || predicate.matches(event)) {
answer.addEvent(Logs.newInstance(event));
matched += 1;
if (count > 0 && matched >= count) {
break;
}
}
}
}
}
}
} else {
LOG.warn("No VmLogAppender available!");
}
answer.setFromTimestamp(from);
answer.setToTimestamp(to);
return answer;
}
use of org.ops4j.pax.logging.spi.PaxLoggingEvent in project ddf by codice.
the class LogFailoverAlertAppender method doAppend.
@Override
public void doAppend(PaxLoggingEvent event) {
if (lastUpdated == null) {
lastUpdated = DateTime.now();
} else if (DateTime.now().isBefore(lastUpdated.plusSeconds(5))) {
// don't spam the admin console when multiple log messages come in at once
return;
}
SystemNotice notice = new SystemNotice(LogFailoverAlertAppender.class.toString(), NoticePriority.CRITICAL, "Audit Logging Failure", details);
eventAdmin.postEvent(new Event(SystemNotice.SYSTEM_NOTICE_BASE_TOPIC.concat("audit"), notice.getProperties()));
lastUpdated = DateTime.now();
}
Aggregations