Automatr.AutomatrLog.Log C# (CSharp) Method

Log() public static method

public static Log ( string message, LogLevel level = LogLevel.Verbose ) : void
message string
level LogLevel
return void
        public static void Log(string message, LogLevel level = LogLevel.Verbose)
        {
            Log(message, true, level);
        }

Same methods

AutomatrLog::Log ( string message, bool newLine, LogLevel level = LogLevel.Verbose ) : void

Usage Example

Example #1
0
        private void RunTasks()
        {
            AutomatrLog.Log("Running tasks... " + (Program.Options.Force ? "(forced)" : ""));
            foreach (AutomatrTask task in Config.Tasks)
            {
                AutomatrLog.Log("Running Task: " + task.Command);
                var processInfo = new ProcessStartInfo("cmd.exe", "/c " + task.Command);
                processInfo.CreateNoWindow         = true;
                processInfo.UseShellExecute        = false;
                processInfo.RedirectStandardError  = true;
                processInfo.RedirectStandardOutput = true;

                var process = Process.Start(processInfo);

                process.OutputDataReceived += (object sender, DataReceivedEventArgs e) => AutomatrLog.Log(e.Data, AutomatrLog.LogLevel.Info);
                process.BeginOutputReadLine();

                process.ErrorDataReceived += (object sender, DataReceivedEventArgs e) => AutomatrLog.Log(e.Data, AutomatrLog.LogLevel.Error);
                process.BeginErrorReadLine();

                process.WaitForExit();

                Console.WriteLine("Exit Code: {0}", process.ExitCode);
                process.Close();
            }
        }
All Usage Examples Of Automatr.AutomatrLog::Log