示例#1
0
        public void Init(LogLocations settings)
        {
            _logFiles = settings.Log;
            foreach (var path in _logFiles)
            {
                var dir = System.IO.Path.GetDirectoryName(path);

                // connect to UNC path
                if (dir.Contains("\\\\"))
                {
                    ExtremeMirror.PinvokeWindowsNetworking.connectToRemote(dir,
                                                                           ConfigurationManager.AppSettings["username"],
                                                                           ConfigurationManager.AppSettings["password"]
                                                                           );
                }

                // set up watcher for the directory & files
                var fw     = new FileSystemWatcher(dir);
                var filter = "";

                if (path.Contains("*."))
                {
                    filter    = path.Substring(path.IndexOf("*."));
                    fw.Filter = filter;
                }

                // set up file sizes so we can diff old vs new
                var files = Directory.GetFiles(Path.GetDirectoryName(path), filter);
                SetupFiles(files);

                fw.Changed            += fw_Changed;
                fw.EnableRaisingEvents = true;
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            LogLocations settings = (LogLocations)ConfigurationManager.GetSection("logLocations");

            var app = new MultiTailApp();

            app.Init(settings);

            // any key to quit
            Console.ReadLine();
        }
示例#3
0
        public object Create(object parent, object configContext, System.Xml.XmlNode section)
        {
            var          szConfig = section.SelectNodes("//logLocations/log");
            LogLocations retConf  = new LogLocations();

            if (szConfig != null)
            {
                foreach (XmlNode node in szConfig)
                {
                    retConf.Log.Add(node.InnerText);
                }
            }

            return(retConf);
        }