public static WriteLine ( string format ) : void | ||
format | string | |
Résultat | void |
public static void WriteExceptionMessage(Exception exception, string format, params object[] args) { string message = string.Format(format, args); string exceptionMessage = string.Format("{0}: {1}", exception.GetType(), exception.Message); message = string.Format("{0}. {1}", message, exceptionMessage); CommonLog.WriteLine(message); }
public void Run() { this.LogFileName = string.Format("{0}.txt", Guid.NewGuid()); this.process.StartInfo.Arguments = string.Format("/c ( \"{0}\" {1} ) > {2} 2>&1", this.FileName, this.Arguments, this.LogFileName); this.process.StartInfo.FileName = "cmd.exe"; if (string.IsNullOrEmpty(this.WorkingDirectory)) { this.WorkingDirectory = Environment.CurrentDirectory; } this.process.StartInfo.WorkingDirectory = this.WorkingDirectory; if (!Directory.Exists(this.process.StartInfo.WorkingDirectory)) { Directory.CreateDirectory(this.process.StartInfo.WorkingDirectory); } CommonLog.WriteLine("Executing: {0} {1}", this.process.StartInfo.FileName, this.process.StartInfo.Arguments); CommonLog.WriteLine("WorkingDirectory: {0}", this.process.StartInfo.WorkingDirectory); bool started = this.process.Start(); if (!started) { throw new Exception("Failed to start process"); } bool exited = this.process.WaitForExit(this.Timeout); if (!exited) { this.process.Kill(); } this.LogFileName = Path.Combine(this.process.StartInfo.WorkingDirectory, this.LogFileName); if (this.ShowOutputInTestLog) { CommonLog.WriteLine(Environment.NewLine + File.ReadAllText(this.LogFileName)); File.Delete(this.LogFileName); } else { CommonLog.WriteLine("LogFile: {0}", this.LogFileName); } if (!exited) { throw new Exception("Process timeout"); } if (this.process.ExitCode != 0 && !this.IgnoreExitCodes.Contains(this.process.ExitCode)) { throw new Exception(string.Format("Process Exit Code is {0}", this.process.ExitCode)); } }
public static void WriteExceptionMessage(Exception exception) { string message = string.Format("{0}: {1}", exception.GetType(), exception.Message); CommonLog.WriteLine(message); }
public static void WriteException(Exception exception) { CommonLog.WriteLine(exception.ToString()); }