예제 #1
0
 private void Log(string text, ChmLogLevel level)
 {
     if (ui != null)
     {
         ui.Log("Tidy: " + text, level);
     }
 }
예제 #2
0
        /// <summary>
        /// Writes the content of a stream to the user interface.
        /// </summary>
        /// <param name="ui">User interface where to write the stream content</param>
        /// <param name="reader">The stream to write</param>
        /// <param name="logLevel">The log level for the log messages</param>
        static public void LogStream(UserInterface ui, StreamReader reader, ChmLogLevel logLevel)
        {
            string linea = reader.ReadLine();

            while (linea != null)
            {
                ui.Log(linea, logLevel);
                linea = reader.ReadLine();
            }
        }
예제 #3
0
        /// <summary>
        /// Writes conditionally a log text.
        /// If the log level of the message is higher than ChmLogLevel member, its not written.
        /// </summary>
        /// <param name="text">Text to log</param>
        /// <param name="level">Log level of the message</param>
        public void Log(string text, ChmLogLevel level)
        {
            // Set the minimum level
            if (level < MinimumChmLogLevel)
            {
                MinimumChmLogLevel = level;
            }

            // Check is we want to show this level message
            if (level <= this.LogLevel)
            {
                Log(text);
            }
        }
예제 #4
0
        /// <summary>
        /// Set the application exit code from a level log message value.
        /// </summary>
        /// <remarks>
        /// Will set 0 all was ok, 1 if there was errors and 2 if there was warnings.
        /// </remarks>
        /// <param name="logLevel">The log level. ChmLogLevel.ERROR, .WARNING, etc.</param>
        static public void SetAplicationExitCode(ChmLogLevel logLevel)
        {
            switch (logLevel)
            {
            case ChmLogLevel.DEBUG:
            case ChmLogLevel.INFO:
                Environment.ExitCode = 0;
                break;

            case ChmLogLevel.WARNING:
                Environment.ExitCode = 1;
                break;

            case ChmLogLevel.ERROR:
                Environment.ExitCode = 2;
                break;
            }
        }
예제 #5
0
 /// <summary>
 /// Generates the project file
 /// </summary>
 protected override void GenerateProject()
 {
     if (OutputQuiet)
     {
         GenerateOnConsole();
     }
     else
     {
         ChmProcessorForm frm             = new ChmProcessorForm(ProjectFile);
         ChmLogLevel      minimumLogLevel =
             frm.ProcessProject(AskConfirmations, ExitAfterGenerate, LogLevel);
         if (!ExitAfterGenerate)
         {
             Application.Run(frm);
         }
         else
         {
             SetAplicationExitCode(minimumLogLevel);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Process the command line parameters
        /// </summary>
        /// <param name="argv">The command line parameters</param>
        protected void ReadCommandLine(string[] argv)
        {
            int i = 0;

            while (i < argv.Length)
            {
                if (argv[i].StartsWith("/"))
                {
                    // Option:
                    argv[i] = argv[i].ToLower();
                    if (argv[i].Equals("/g"))
                    {
                        // Generate at windows:
                        Op = ConsoleOperation.Generate;
                    }
                    else if (argv[i].Equals("/y"))
                    {
                        // Dont ask for confirmations
                        AskConfirmations = false;
                    }
                    else if (argv[i].Equals("/e"))
                    {
                        ExitAfterGenerate = true;
                    }
                    else if (argv[i].Equals("/?"))
                    {
                        Op = ConsoleOperation.ShowHelp;
                    }
                    else if (argv[i].Equals("/q"))
                    {
                        OutputQuiet = true;
                    }
                    else if (argv[i].Equals("/l1"))
                    {
                        LogLevel = ChmLogLevel.ERROR;
                    }
                    else if (argv[i].Equals("/l2"))
                    {
                        LogLevel = ChmLogLevel.WARNING;
                    }
                    else if (argv[i].Equals("/l3"))
                    {
                        LogLevel = ChmLogLevel.INFO;
                    }
                    else if (argv[i].Equals("/l4"))
                    {
                        LogLevel = ChmLogLevel.DEBUG;
                    }
                    else
                    {
                        Message("Unknown option " + argv[i]);
                        Op = ConsoleOperation.ShowHelp;
                        SetAplicationExitCode(ChmLogLevel.ERROR);
                    }
                }
                else
                {
                    ProjectFile = argv[i];
                }
                i++;
            }
        }
예제 #7
0
        public GenerationDialog(ChmProject project, bool exitAfterEnd, bool askConfirmations, ChmLogLevel logLevel)
        {
            InitializeComponent();

            this.ExitAfterEnd     = exitAfterEnd;
            this.AskConfirmations = askConfirmations;

            this.UI          = new GenerationDialogUserInterface(this);
            this.UI.LogLevel = logLevel;

            this.Processor = new DocumentProcessor(project, UI);

            BgWorker.RunWorkerAsync();
        }
예제 #8
0
 /// <summary>
 /// Constructor
 /// </summary>
 public ConsoleUserInterface()
 {
     MinimumChmLogLevel = ChmLogLevel.DEBUG;
 }
예제 #9
0
 /// <summary>
 /// Writes the content of a stream to the user interface.
 /// </summary>
 /// <param name="reader">The stream to write</param>
 /// <param name="logLevel">The log level for the log messages</param>
 public void LogStream(StreamReader reader, ChmLogLevel logLevel)
 {
     LogStream(this, reader, logLevel);
 }
예제 #10
0
 /// <summary>
 /// Called by the generation process to add an exception to the log.
 /// Its written to the console.
 /// </summary>
 /// <param name="text">Exception to log</param>
 public virtual void Log(Exception exception)
 {
     MinimumChmLogLevel = ChmLogLevel.ERROR;
     Console.WriteLine(exception.ToString());
 }