Search in sources :

Example 1 with PaxLoggingEvent

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;
}
Also used : PaxLoggingEvent(org.ops4j.pax.logging.spi.PaxLoggingEvent)

Example 2 with PaxLoggingEvent

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"));
}
Also used : Task(org.cytoscape.work.Task) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) AbstractTaskFactory(org.cytoscape.work.AbstractTaskFactory) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) PaxLoggingEvent(org.ops4j.pax.logging.spi.PaxLoggingEvent) TaskManager(org.cytoscape.work.TaskManager) TaskIterator(org.cytoscape.work.TaskIterator) TaskMonitor(org.cytoscape.work.TaskMonitor) ExecutorService(java.util.concurrent.ExecutorService)

Example 3 with PaxLoggingEvent

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);
    }
}
Also used : PaxLoggingEvent(org.ops4j.pax.logging.spi.PaxLoggingEvent)

Example 4 with PaxLoggingEvent

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;
}
Also used : PaxLoggingEvent(org.ops4j.pax.logging.spi.PaxLoggingEvent) LogResults(io.fabric8.insight.log.LogResults) LruList(org.apache.karaf.shell.log.LruList)

Example 5 with PaxLoggingEvent

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();
}
Also used : PaxLoggingEvent(org.ops4j.pax.logging.spi.PaxLoggingEvent) Event(org.osgi.service.event.Event) SystemNotice(org.codice.ddf.system.alerts.SystemNotice)

Aggregations

PaxLoggingEvent (org.ops4j.pax.logging.spi.PaxLoggingEvent)8 LogResults (io.fabric8.insight.log.LogResults)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 LinkedBlockingQueue (java.util.concurrent.LinkedBlockingQueue)1 LruList (org.apache.karaf.shell.log.LruList)1 SystemNotice (org.codice.ddf.system.alerts.SystemNotice)1 CySwingApplication (org.cytoscape.application.swing.CySwingApplication)1 AbstractTaskFactory (org.cytoscape.work.AbstractTaskFactory)1 Task (org.cytoscape.work.Task)1 TaskIterator (org.cytoscape.work.TaskIterator)1 TaskManager (org.cytoscape.work.TaskManager)1 TaskMonitor (org.cytoscape.work.TaskMonitor)1 Event (org.osgi.service.event.Event)1