private static bool Run(string[] args) { Console.OutputEncoding = Encoding.UTF8; var ctx = new Context(); ctx.Options = CliParser.Parse(args); if (ctx.Options == null) { return(false); } StreamWriter logWriter = null; try { using (var logger = new ProgressBar()) { ctx.Logger = logger; ctx.Horizon = new Horizon(new TimeSpanTimer()); if (ctx.Options.AccessLog != null) { logWriter = new StreamWriter(ctx.Options.AccessLog); var accessLog = new TextWriterAccessLog(logWriter); ctx.Horizon.Fs.SetAccessLog(true, accessLog); } OpenKeyset(ctx); if (ctx.Options.RunCustom) { CustomTask(ctx); return(true); } RunTask(ctx); } } finally { logWriter?.Dispose(); } return(true); }
private static bool Run(string[] args) { Console.OutputEncoding = Encoding.UTF8; var ctx = new Context(); ctx.Options = CliParser.Parse(args); if (ctx.Options == null) { return(false); } StreamWriter logWriter = null; ResultLogger resultLogger = null; try { using (var logger = new ProgressBar()) { ctx.Logger = logger; ctx.FsClient = new FileSystemClient(new StopWatchTimeSpanGenerator()); if (ctx.Options.AccessLog != null) { logWriter = new StreamWriter(ctx.Options.AccessLog); var accessLog = new TextWriterAccessLog(logWriter); ctx.FsClient.SetAccessLogTarget(AccessLogTarget.All); ctx.FsClient.SetGlobalAccessLogMode(GlobalAccessLogMode.Log); ctx.FsClient.SetAccessLogObject(accessLog); } if (ctx.Options.ResultLog != null) { resultLogger = new ResultLogger(new StreamWriter(ctx.Options.ResultLog), printStackTrace: true, printSourceInfo: true, combineRepeats: true); Result.SetLogger(resultLogger); } OpenKeyset(ctx); if (ctx.Options.RunCustom) { CustomTask(ctx); return(true); } RunTask(ctx); } } finally { logWriter?.Dispose(); if (resultLogger != null) { Result.SetLogger(null); resultLogger.Dispose(); } } return(true); }
private static bool Run(string[] args) { Console.OutputEncoding = Encoding.UTF8; var ctx = new Context(); ctx.Options = CliParser.Parse(args); if (ctx.Options == null) { return(false); } StreamWriter logWriter = null; StreamWriter resultWriter = null; try { Result.GetResultNameHandler = ResultLogFunctions.TryGetResultName; using (var logger = new ProgressBar()) { ctx.Logger = logger; ctx.Horizon = new Horizon(new StopWatchTimeSpanGenerator()); if (ctx.Options.AccessLog != null) { logWriter = new StreamWriter(ctx.Options.AccessLog); var accessLog = new TextWriterAccessLog(logWriter); ctx.Horizon.Fs.SetLocalAccessLogMode(LocalAccessLogMode.All); ctx.Horizon.Fs.SetGlobalAccessLogMode(GlobalAccessLogMode.Log); ctx.Horizon.Fs.SetAccessLogObject(accessLog); } if (ctx.Options.ResultLog != null) { resultWriter = new StreamWriter(ctx.Options.ResultLog); ResultLogFunctions.LogWriter = resultWriter; Result.LogCallback = ResultLogFunctions.LogResult; Result.ConvertedLogCallback = ResultLogFunctions.LogConvertedResult; } OpenKeyset(ctx); if (ctx.Options.RunCustom) { CustomTask(ctx); return(true); } RunTask(ctx); } } finally { logWriter?.Dispose(); resultWriter?.Dispose(); ResultLogFunctions.LogWriter = null; } return(true); }