コード例 #1
0
        public static void Run(string host)
        {
            List <string> logs = ReaderLog.Files;

            foreach (string logname in logs)
            {
                Console.WriteLine("Start downloading {0} ...", logname);

                string logpath = Path.Combine("/tmp", logname);
                try
                {
                    ReaderUtil.DownloadLog(host, logname, logpath, (ln, perc) =>
                    {
                        Console.WriteLine("Downloading {0}: {1}%\r", logname, perc);
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
        }
コード例 #2
0
        public static void Run(string host)
        {
            string logname = ReaderLog.FS_LS;
            string logpath = Path.Combine("/tmp", logname);

            if (!File.Exists(logpath))
            {
                Console.WriteLine("Start downloading {0} ...", logname);

                try
                {
                    ReaderUtil.DownloadLog(host, logname, logpath, (ln, perc) =>
                    {
                        Console.WriteLine("Downloading {0}: {1}%\r", logname, perc);
                    });
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }

            string line = null;

            using (StreamReader reader = new StreamReader(logpath))
            {
                while ((line = reader.ReadLine()) != null)
                {
                    string   tag = ReaderDecoder.ExtractTagID(line);
                    DateTime?dt  = ReaderDecoder.ExtractDateTime(line);
                    if (dt.HasValue)
                    {
                        Console.WriteLine("{0}:{1}", tag, dt.Value);
                    }
                }
            }
        }