public static SetLoggers ( Action |
||
debug | Action |
|
info | Action |
|
warn | Action |
|
error | Action |
|
Результат | void |
static void ConfigureLogging(Arguments arguments) { var writeActions = new List <Action <string> > { s => log.AppendLine(s) }; if (arguments.Output == OutputType.BuildServer || arguments.LogFilePath == "console" || arguments.Init) { writeActions.Add(Console.WriteLine); } if (arguments.LogFilePath != null && arguments.LogFilePath != "console") { try { Directory.CreateDirectory(Path.GetDirectoryName(arguments.LogFilePath)); if (File.Exists(arguments.LogFilePath)) { using (File.CreateText(arguments.LogFilePath)) { } } writeActions.Add(x => WriteLogEntry(arguments, x)); } catch (Exception ex) { Console.WriteLine("Failed to configure logging: " + ex.Message); } } Logger.SetLoggers( s => writeActions.ForEach(a => a(s)), s => writeActions.ForEach(a => a(s)), s => writeActions.ForEach(a => a(s))); }
public WriteVersionInfoToBuildLog() { logger = new TaskLogger(this); fileSystem = new FileSystem(); Logger.SetLoggers( this.LogInfo, this.LogWarning, s => this.LogError(s)); }
public GetVersion() { logger = new TaskLogger(this); fileSystem = new FileSystem(); Logger.SetLoggers( this.LogInfo, this.LogWarning, s => this.LogError(s)); }
public UpdateAssemblyInfo() { CompileFiles = new ITaskItem[] { }; logger = new TaskLogger(this); fileSystem = new FileSystem(); Logger.SetLoggers( this.LogInfo, this.LogWarning, s => this.LogError(s)); }
static void ConfigureLogging(Arguments arguments) { var writeActions = new List <Action <string> > { s => log.AppendLine(s) }; if (arguments.Output == OutputType.BuildServer || arguments.LogFilePath == "console" || arguments.Init) { writeActions.Add(Console.WriteLine); } Exception exception = null; if (arguments.LogFilePath != null && arguments.LogFilePath != "console") { try { var logFileFullPath = Path.GetFullPath(arguments.LogFilePath); var logFile = new FileInfo(logFileFullPath); // NOTE: logFile.Directory will be null if the path is i.e. C:\logfile.log. @asbjornu if (logFile.Directory != null) { logFile.Directory.Create(); } using (logFile.CreateText()) { } writeActions.Add(x => WriteLogEntry(arguments, x)); } catch (Exception ex) { exception = ex; } } Logger.SetLoggers( s => writeActions.ForEach(a => a(s)), s => writeActions.ForEach(a => a(s)), s => writeActions.ForEach(a => a(s))); if (exception != null) { Logger.WriteError(string.Format("Failed to configure logging for '{0}': {1}", arguments.LogFilePath, exception.Message)); } }