Package org.osgi.service.log

Examples of org.osgi.service.log.LogEntry


    for(Enumeration e = logReaders.keys(); e.hasMoreElements(); ) {
      ServiceReference sr = (ServiceReference)e.nextElement();
      LogReaderService lr = (LogReaderService)logReaders.get(sr);

      for(Enumeration e2 = lr.getLog(); e2.hasMoreElements(); ) {
        LogEntry entry = (LogEntry)e2.nextElement();
        logged(entry);
      }
    }
  }
View Full Code Here


  private Vector getLog(List logEvents) {
    Vector result = new Vector();

    try {
      for(Iterator iter = logEvents.iterator(); iter.hasNext(); ) {
        LogEntry entry = (LogEntry) iter.next();
        result.addElement(new Long(entry.getBundle().getBundleId()));
        result.addElement(new Integer(entry.getLevel()));
        result.addElement(entry.getMessage());
        result.addElement(new Long(entry.getTime()));
        Throwable e = entry.getException();
        if (e == null) {
          result.addElement("-");
          result.addElement("-");
          result.addElement("-");
        } else {
View Full Code Here

          System.out.println("doLogEvents ");
        }

        Vector vector = fw.getLog();
        for (Iterator events = vector.iterator(); events.hasNext();) {
          LogEntry entry = (LogEntry) events.next();
          for (Iterator listeners = logListeners.iterator(); listeners.hasNext();) {
            LogListener listener = (LogListener) listeners.next();
            listener.logged(entry);
          }
        }
View Full Code Here

                        Enumeration e = lr.getLog();
                        Vector lv = new Vector();
                        boolean rflag = opts.get("-r") == null;
                        while (e.hasMoreElements()) {
                            LogEntry le = (LogEntry) e.nextElement();
                            Bundle b = le.getBundle();
                            if (b == null && fflag || bv == null && !fflag
                                    || bv != null && bv.contains(b)) {
                                if (count-- <= 0) {
                                    break;
                                }
                                if (le.getLevel() > level) {
                                    continue;
                                }
                                if (le.getTime() < startTime) {
                                    break;
                                }
                                if (rflag) {
                                    lv.insertElementAt(le, 0);
                                } else {
                                    lv.addElement(le);
                                }
                            }
                        }

                        StringBuffer sb = new StringBuffer();
                        SimpleDateFormat tf = new SimpleDateFormat(
                                "MMM dd HH:mm:ss ");

                        for (e = lv.elements(); e.hasMoreElements();) {
                            LogEntry le = (LogEntry) e.nextElement();
                            sb.setLength(0);
                            sb.append(tf.format(new Date(le.getTime())));
                            pad(sb, 16);
                            switch (le.getLevel()) {
                            case LogService.LOG_INFO:
                                sb.append("INFO");
                                break;
                            case LogService.LOG_DEBUG:
                                sb.append("DEBUG");
                                break;
                            case LogService.LOG_WARNING:
                                sb.append("WARNING");
                                break;
                            case LogService.LOG_ERROR:
                                sb.append("ERROR");
                                break;
                            default:
                                sb.append("UNKNOWN");
                                break;
                            }
                            pad(sb, 23);
                            Bundle b = le.getBundle();
                            if (b != null) {
                                sb.append(" #" + b.getBundleId());
                                pad(sb, 28);
                                sb.append(Util.shortName(b));
                            } else {
                                sb.append(" FRAMEWORK");
                            }
                            pad(sb, 42);
                            sb.append(" - ");
                            sb.append(le.getMessage());
                            final ServiceReference leSr
                              = le.getServiceReference();
                            if (leSr != null) {
                              sb.append(", Service#");
                              sb.append(leSr.getProperty(Constants.SERVICE_ID));
                              sb.append(": ");
                              sb.append(Util.showServiceClasses(leSr));
                            }
                            out.println(sb.toString());
                            if (le.getException() != null
                                    && opts.get("-s") != null) {
                                le.getException().printStackTrace(out);
                            }
                        }
                        bc.ungetService(sr);
                        return new Integer(0);
                    }
View Full Code Here

                break;
            default:
                message = "BundleEvent " + event.getType();
        }

        LogEntry entry = new LogEntryImpl(event.getBundle(), null,
            LogService.LOG_INFO, message, null);
        fireLogEvent(entry);
    }
View Full Code Here

        String s = (event.getServiceReference().getBundle() == null)
                ? null
                : "Bundle " + event.getServiceReference().getBundle();
        s = (s == null) ? message : s + " " + message;

        LogEntry entry = new LogEntryImpl(
            event.getServiceReference().getBundle(),
            event.getServiceReference(), level, message, null);
        fireLogEvent(entry);
    }
View Full Code Here

        String s = (event.getBundle() == null) ? null : "Bundle "
            + event.getBundle();
        s = (s == null) ? message : s + " " + message;

        LogEntry entry = new LogEntryImpl(event.getBundle(), null, level,
            message, exception);
        fireLogEvent(entry);
    }
View Full Code Here

         */
        @Override
        public void run() {
            while (active) {

                LogEntry logEntry = null;
                try {
                    logEntry = dequeueLogEntry();
                } catch (InterruptedException ie) {
                    // don't care, this is expected
                }
View Full Code Here

        }

        public void log(ServiceReference sr, int level, String message,
                Throwable exception) {
            // simply fire a log event
            LogEntry entry = new LogEntryImpl(this.bundle, sr, level, message,
                exception);
            LogServiceFactory.this.logSupport.fireLogEvent(entry);
        }
View Full Code Here

            int minLevel = logLevelAsInt(logLevel);

            int index = 0;
            while (entries.hasMoreElements() && (maxEntries < 0 || index < maxEntries))
            {
                LogEntry entry = (LogEntry) entries.nextElement();
                if (entry.getLevel() <= minLevel)
                {
                    display(entry);
                    index++;
                }
            }
View Full Code Here

TOP

Related Classes of org.osgi.service.log.LogEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.