private static void SetupWatchers() { // Read config file var configFile = XDocument.Load("configureLogs.xml"); string MasterLogLocation = configFile.Element("sources").Element("masterLog").Value; // Set up MasterLogFile MasterLogWriter masterLogger = new MasterLogWriter(); masterLogger.masterLogLocation = MasterLogLocation; Console.WriteLine("MasterLog location: {0}", MasterLogLocation); var sources = configFile.Descendants("logSource"); foreach (XElement logSource in sources) { switch (logSource.Element("type").Value) { case "txt": Console.WriteLine("Setting up Text Log file"); LogFileHandler lfh = new LogFileHandler(masterLogger, logSource.Element("location").Value, logSource.Element("formatString").Value); break; case "dbTable": Console.WriteLine("Setting up db Table logger"); dbTableHandler dbTH = new dbTableHandler(masterLogger, logSource.Element("connStr").Value, logSource.Element("query").Value, logSource.Element("formatString").Value, logSource.Element("timeStamp").Value, logSource.Element("errorColumn").Value, logSource.Element("pollingInterval").Value); break; case "xml": Console.WriteLine("Setting up xml file logger"); XMLHandler xmlH = new XMLHandler(masterLogger, logSource.Element("location").Value, logSource.Element("formatString").Value, logSource.Element("groupTag").Value, logSource.Element("timeStampTag").Value, logSource.Element("pollingInterval").Value); break; case "csv": Console.WriteLine("Setting up csv file logger"); CSVFileHandler textHandler = new CSVFileHandler(masterLogger, logSource.Element("location").Value, logSource.Element("formatString").Value, logSource.Element("ignoreTitleRow").Value); break; } } Console.ReadKey(); }
public LogFileHandler(MasterLogWriter mlw, string fileLocation, string fileFormat) { location = fileLocation; formatString = fileFormat; masterLogger = mlw; spawnWatcher(); }
public CSVFileHandler(MasterLogWriter masterLogWrtr, string fileLocation, string formatStr, string ignoreTitleRow) { mlw = masterLogWrtr; location = fileLocation; formatString = formatStr; if (ignoreTitleRow.ToLower() == "yes") { ignoreFirstLine = true; } spawnWatcher(); }
public dbTableHandler(MasterLogWriter mlw, string connectionString, string query, string formatString, string timeStampColumn, string errorColumn, string pollTime) { masterLogger = mlw; connStr = connectionString; selectQuery = query; timeColumn = timeStampColumn; errColumn = errorColumn; outputString = formatString; lastTimeProcessed = DateTime.MinValue; // Get all rows currently in table InterogateTable(); // Set up timer to check table every interval Timer timer = new Timer(Convert.ToInt32(pollTime)); timer.Elapsed += OnTimerTick; timer.Enabled = true; }
public XMLHandler(MasterLogWriter masterLogger, string location, string formatString, string groupTag, string timeStamp, string pollingInterval) { mlw = masterLogger; xmlFileLocation = location; formatStr = formatString; timeStampTag = timeStamp; groupTagName = groupTag; InitialProcessXMLFile(); //SpawnWatcher(); Timer t = new Timer(Convert.ToDouble(pollingInterval)); t.Elapsed += ProcessXMLOnChange; t.Enabled = true; }