Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Small code optimizations. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | develop |
Files: | files | file ages | folders |
SHA1: |
3bd88a018488629663e23d148acd2051 |
User & Date: | tinus 2018-06-28 19:57:59.622 |
Context
2021-01-18
| ||
09:56 | Updates to U_ZaapSentinel2.pas check-in: 43434e8fc7 user: tinus tags: develop | |
2018-06-28
| ||
19:57 | Small code optimizations. check-in: 3bd88a0184 user: tinus tags: develop | |
2018-05-31
| ||
05:59 | Bugfix: /? help now works. Enhanced: when the /verbose flag is specified, show the full stack track for exceptions. Refactor: increased code readability by not using `var` when it's not apparent at first glance what the type is going to be. check-in: b80ceff467 user: tinus tags: develop | |
Changes
Changes to ZTUpdater/Program.cs.
︙ | ︙ | |||
82 83 84 85 86 87 88 | FilesUpdated = UpdateTask.Result; } WriteLog($"{FilesUpdated} files updated.", TraceLevel.Info); return FilesUpdated > 0 ? 0 : 1; } catch (Exception ex) { | | < > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | FilesUpdated = UpdateTask.Result; } WriteLog($"{FilesUpdated} files updated.", TraceLevel.Info); return FilesUpdated > 0 ? 0 : 1; } catch (Exception ex) { bool WriteException(Exception iex) { if (MinimumLevel >= TraceLevel.Verbose) Console.Error.WriteLine(iex.ToString()); else Console.Error.WriteLine(iex.Message); return true; } var BackupColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Magenta; if (ex is AggregateException) ((AggregateException)ex).Handle(WriteException); else WriteException(ex); Console.ForegroundColor = BackupColor; |
︙ | ︙ | |||
170 171 172 173 174 175 176 | if (level <= minimumLevel) { WriteLog(message, level); } }; } | | > > > > > < < < < < < | 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | if (level <= minimumLevel) { WriteLog(message, level); } }; } private static readonly Dictionary<TraceLevel, ConsoleColor> _levelColors = new Dictionary<TraceLevel, ConsoleColor> { { TraceLevel.Verbose, ConsoleColor.DarkGray }, { TraceLevel.Warning, ConsoleColor.Yellow }, { TraceLevel.Error, ConsoleColor.Red }, }; private static void WriteLog(string message, TraceLevel level) { var Output = level >= TraceLevel.Warning ? Console.Out : Console.Error; var BackupColor = Console.ForegroundColor; if (_levelColors.TryGetValue(level, out var Color)) Console.ForegroundColor = Color; Output.WriteLine(message); Console.ForegroundColor = BackupColor; } |
︙ | ︙ |