/[xmltv_parser]/trunk/GBPVRProgramDatabaseFixer/Program.cs
ViewVC logotype

Diff of /trunk/GBPVRProgramDatabaseFixer/Program.cs

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

revision 240 by william, Sun Mar 17 10:12:28 2013 UTC revision 241 by william, Sun Mar 17 10:40:09 2013 UTC
# Line 16  namespace GBPVRProgramDatabaseFixer Line 16  namespace GBPVRProgramDatabaseFixer
16  {  {
17      class Program      class Program
18      {      {
19            const long MAX_LOG_FILESIZE_IN_BYTES = 250000; //250kb max
20            static void TruncateLogFile(FileInfo log_file)
21            {
22                if (!log_file.Exists)
23                {
24                    gLog.CreateLog(log_file.FullName, false, LogLevel.kLogLevel_All);
25                }
26                else
27                {
28                    if (log_file.Length > MAX_LOG_FILESIZE_IN_BYTES)
29                    {
30                        string match = string.Format("{0}.*", log_file.Name);
31                        var files = Directory.GetFiles(log_file.Directory.FullName, match).ToList();
32                        files.RemoveAt(0);
33                        files.TrimExcess();
34                        int count = files.Count;
35                        if (log_file.Exists)
36                        {
37                            File.Copy(log_file.FullName, string.Format("{0}.{1}", log_file.FullName, count));
38                        }
39                        gLog.CreateLog(log_file.FullName, true, LogLevel.kLogLevel_All);
40                    }
41                    else
42                    {
43                        gLog.CreateLog(log_file.FullName, false, LogLevel.kLogLevel_All);
44                    }
45                }
46            }
47    
48          static ISQLLITE sqlite;          static ISQLLITE sqlite;
49          static string XMLTV_FILE = "";          static string XMLTV_FILE = "";
50          static string GBPVR_DATABASE = "";          static string GBPVR_DATABASE = "";
# Line 37  namespace GBPVRProgramDatabaseFixer Line 66  namespace GBPVRProgramDatabaseFixer
66          {          {
67              string log_path = Application.StartupPath;              string log_path = Application.StartupPath;
68              string log_filename = string.Format("{0}.log", typeof(Program).Assembly.GetName().Name);              string log_filename = string.Format("{0}.log", typeof(Program).Assembly.GetName().Name);
69              gLog.CreateLog(string.Format(@"{0}\{1}", log_path, log_filename), false, LogLevel.kLogLevel_All);              FileInfo log_file = new FileInfo(string.Format(@"{0}\{1}", log_path, log_filename));
70                TruncateLogFile(log_file);
71  #if DEBUG  #if DEBUG
72              LogLevel gLevel = gLog.LogLevel;              LogLevel gLevel = gLog.LogLevel;
73              gLevel |= LogLevel.kLogLevel_VerboseDebug;              gLevel |= LogLevel.kLogLevel_VerboseDebug;

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

  ViewVC Help
Powered by ViewVC 1.1.22