public static SetLoggers ( Action |
||
debug | Action |
|
info | Action |
|
warn | Action |
|
error | Action |
|
return | void |
public static void SetLoggers(Action<string> debug, Action<string> info, Action<string> warn, Action<string> error)
{
if (debug == null) throw new ArgumentNullException("debug");
if (info == null) throw new ArgumentNullException("info");
if (warn == null) throw new ArgumentNullException("warn");
if (error == null) throw new ArgumentNullException("error");
WriteDebug = LogMessage(ObscurePassword(debug), "DEBUG");
WriteInfo = LogMessage(ObscurePassword(info), "INFO");
WriteWarning = LogMessage(ObscurePassword(warn), "WARN");
WriteError = LogMessage(ObscurePassword(error), "ERROR");
}
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))); }