/[xmltv_parser]/trunk/xmltv_parser/main.cs
ViewVC logotype

Diff of /trunk/xmltv_parser/main.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 227 by william, Sun Mar 17 03:57:57 2013 UTC revision 241 by william, Sun Mar 17 10:40:09 2013 UTC
# Line 23  namespace xmltv_parser Line 23  namespace xmltv_parser
23    
24      public partial class main : Form      public partial class main : Form
25      {      {
26            const long MAX_LOG_FILESIZE_IN_BYTES = 250000; //250kb max
27            void TruncateLogFile(FileInfo log_file)
28            {
29                if (!log_file.Exists)
30                {
31                    gLog.CreateLog(log_file.FullName, false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
32                }
33                else
34                {
35                    if (log_file.Length > MAX_LOG_FILESIZE_IN_BYTES)
36                    {
37                        string match = string.Format("{0}.*", log_file.Name);
38                        var files = Directory.GetFiles(log_file.Directory.FullName, match).ToList();
39                        files.RemoveAt(0);
40                        files.TrimExcess();
41                        int count = files.Count;
42                        if (log_file.Exists)
43                        {
44                            File.Copy(log_file.FullName, string.Format("{0}.{1}", log_file.FullName, count));
45                        }
46                        gLog.CreateLog(log_file.FullName, true, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
47                    }
48                    else
49                    {
50                        gLog.CreateLog(log_file.FullName, false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));
51                    }
52                }
53            }
54    
55          public main()          public main()
56          {          {
57              InitializeComponent();              InitializeComponent();
58              ListViewSorter Sorter = new ListViewSorter();              ListViewSorter Sorter = new ListViewSorter();
59              //lstPrograms.ListViewItemSorter = Sorter;              //lstPrograms.ListViewItemSorter = Sorter;
60    
61              string log_path = Application.StartupPath;              string log_path = Application.StartupPath;
62              string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);              string log_filename = string.Format("{0}.log", typeof(main).Assembly.GetName().Name);
63              gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All_NoProgress, new EventHandler<LoggerOnFlushEventArgs>(Log_OnFlush));              FileInfo log_file = new FileInfo(string.Format(@"{0}\{1}", log_path, log_filename));
64                TruncateLogFile(log_file);            
65  #if DEBUG  #if DEBUG
66              LogLevel gLevel = gLog.LogLevel;              LogLevel gLevel = gLog.LogLevel;
67  #if DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG  #if DISABLE_DEBUG_MODE_KLOGLEVEL_VERBOSE_DEBUG

Legend:
Removed from v.227  
changed lines
  Added in v.241

  ViewVC Help
Powered by ViewVC 1.1.22