1 23 24 package com.sun.enterprise.tools.upgrade.logging; 25 26 import java.io.*; 27 import java.util.*; 28 import java.util.logging.*; 29 import java.text.*; 30 import com.sun.enterprise.tools.upgrade.common.*; 31 import com.sun.enterprise.server.logging.UniformLogFormatter; 32 33 38 39 public class LogFormatter extends UniformLogFormatter { 40 41 private static List listenerList = new ArrayList(); 42 43 public String format(LogRecord rec) { 44 72 73 notifyRegisteredListeners(rec.getMessage(),rec); 74 return super.format(rec); 75 } 76 77 private void notifyRegisteredListeners(String msg, LogRecord record){ 78 int size = listenerList.size(); 79 for(int i =0; i<size;i++) { 80 LogMessageListener listener = (LogMessageListener)listenerList.get(i); 81 LogMessageEvent e = new LogMessageEvent("UpgradeTool", msg); 82 e.setLogRecord(record); 83 listener.logMessageReceived(e); 84 } 85 } 86 95 public static void addLogMessageListener(LogMessageListener listener){ 96 listenerList.add(listener); 97 } 98 99 public static void removeLogMessageListener(LogMessageListener listener){ 100 listenerList.remove(listener); 101 } 102 110 } 111 112 | Popular Tags |