1 19 package org.openharmonise.rm.logging; 20 21 import org.openharmonise.commons.dsi.*; 22 import org.openharmonise.rm.config.*; 23 import org.openharmonise.rm.dsi.*; 24 25 26 38 public class EventLogController implements EventLogger { 39 40 43 static EventLogController m_instance = null; 44 45 48 private EventLogger m_logger = null; 49 50 54 private static String PNAME_LOG_OUTPUT = "LOG_OUTPUT"; 55 56 61 public static final String LOGTYPE_DB = "DB"; 62 63 68 public static final String LOGTYPE_XML = "XML"; 69 70 73 protected EventLogController() throws LogException { 74 try { 75 String sLogType = ConfigSettings.getProperty(PNAME_LOG_OUTPUT,"DB"); 76 77 if(sLogType != null) { 78 if(sLogType.equals(LOGTYPE_DB) == true) { 79 m_logger = new DBEventLogger(DataStoreInterfaceFactory.getDataStoreInterface()); 80 } else if(sLogType.equals(LOGTYPE_XML) == true) { 81 m_logger = new XMLEventLogger(); 82 } 83 } else { 84 throw new LogException("Error getting log config setting"); 85 } 86 } catch (ConfigException e) { 87 throw new LogException("Error getting log config setting",e); 88 } catch (DataStoreException e) { 89 throw new LogException("Error getting data store inteface",e); 90 } 91 } 92 93 98 public static EventLogController getInstance() throws LogException { 99 if(m_instance == null) { 100 m_instance = new EventLogController(); 101 } 102 103 return m_instance; 104 } 105 106 109 public void logEvent(LogEvent event) throws LogException { 110 111 if(m_logger != null) { 112 m_logger.logEvent(event); 113 } 114 } 115 116 120 public static void reset(){ 121 m_instance = null; 122 } 123 124 } 125 | Popular Tags |