Esempio n. 1
0
 private void logVersionInfo(Class<?> clazz, String title, Log log) {
   Package pack = clazz.getPackage();
   String version = null;
   if (pack != null) {
     if (pack.getImplementationTitle() != null) {
       title = pack.getImplementationTitle();
     }
     version = pack.getImplementationVersion();
   }
   if (version == null) {
     try {
       String classname = clazz.getName();
       Class<?> packinf =
           Class.forName(classname.substring(0, classname.lastIndexOf('.')) + ".PackageInfo");
       java.lang.reflect.Method mo = packinf.getMethod("getProductVersion");
       version = mo.invoke(null).toString();
     } catch (Exception pie) {
       log.info("PackageInfo not found");
     }
     if (version == null) {
       version = "<unknown>";
     }
   }
   log.info(title + " version " + version);
 }
Esempio n. 2
0
 /** Destroys the TeaServlet and the user's application. */
 public void destroy() {
   if (mEngine != null) {
     mLog.info("Destroying Engine");
     mEngine.destroy();
   }
   mLog.info("Destroying TeaServlet");
   super.destroy();
 }
Esempio n. 3
0
 public synchronized void info(Throwable t) {
   TeaStackTraceLine[] lines = getTeaStackTraceLines(t);
   if (lines == null) {
     super.info(t);
   } else {
     if (isEnabled() && isInfoEnabled()) {
       dispatchLogTeaStackTrace(new TeaLogEvent(this, LogEvent.INFO_TYPE, lines));
     }
   }
 }
Esempio n. 4
0
  private void createMemoryLog(Log log) {

    if (log != null) {

      // Create memory log listener.
      mLogEvents = Collections.synchronizedList(new LinkedList<LogEvent>());

      // The maximum number of log events to store in memory.
      final int logEventsMax = mProperties.getInt("log.max", 100);

      log.addRootLogListener(
          new TeaLogListener() {
            public void logMessage(LogEvent e) {
              checkSize();
              mLogEvents.add(e);
            }

            public void logException(LogEvent e) {
              checkSize();
              mLogEvents.add(e);
            }

            public void logTeaStackTrace(TeaLogEvent e) {
              checkSize();
              mLogEvents.add(e);
            }

            private void checkSize() {
              while (mLogEvents.size() >= logEventsMax) {
                mLogEvents.remove(0);
              }
            }
          });

      logVersionInfo(TeaServlet.class, "TeaServlet", log);
      log.info("Copyright (C) 1999-2012 TeaTrove http://teatrove.org");
      logVersionInfo(TemplateLoader.class, "Tea", log);
      log.info("Copyright (C) 1997-2012 TeaTrove http://teatrove.org");
    }
  }