|
8 | 8 | Log.Logger = new LoggerConfiguration() |
9 | 9 | .MinimumLevel.Debug() |
10 | 10 | .WriteTo.File("logs/app.txt", rollingInterval: RollingInterval.Day) |
| 11 | + .WriteTo.Console() |
11 | 12 | .CreateLogger(); |
12 | 13 |
|
13 | 14 | try |
|
18 | 19 | Environment.Exit(1); |
19 | 20 | } |
20 | 21 |
|
21 | | - Console.WriteLine("wizard - the little helper"); |
| 22 | + Log.Information("wizard - the little helper"); |
22 | 23 |
|
23 | 24 | var applicationDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!; |
24 | 25 | var tempPatchFileDirectory = Path.Combine(applicationDirectory, "TempPatchFiles"); |
|
41 | 42 | Environment.Exit(1); |
42 | 43 | } |
43 | 44 |
|
44 | | - Console.WriteLine($"Found Wizard101 installation at location {installPath}"); |
45 | | - Console.WriteLine($"Wizard101 data version is: {wizard101Version}"); |
| 45 | + Log.Information("Found Wizard101 installation at location {InstallPath}", installPath); |
| 46 | + Log.Information("Wizard101 data version is: {Wizard101Version}", wizard101Version); |
46 | 47 |
|
47 | 48 | directoryManipulator.DestroyGameData(); |
48 | 49 |
|
49 | | - Console.WriteLine("Deleted previously installed GameData and ObjectCache for a fresh installation."); |
50 | | - Console.WriteLine("Downloading LatestFileList.bin to discover all Wizard101 files."); |
| 50 | + Log.Information("Deleted previously installed GameData and ObjectCache for a fresh installation."); |
| 51 | + Log.Information("Downloading LatestFileList.bin to discover all Wizard101 files."); |
51 | 52 |
|
52 | 53 | var patchClientDownloader = new PatchClientDownloader(wizard101Version); |
53 | 54 | await patchClientDownloader.DownloadLatestFileListAsync(tempPatchFileDirectory); |
54 | 55 |
|
55 | | - Console.WriteLine("Downloaded LatestFileList.bin successfully!"); |
| 56 | + Log.Information("Downloaded LatestFileList.bin successfully!"); |
56 | 57 |
|
57 | 58 | var latestFileListExtractor = |
58 | 59 | new LatestFileListExtractor(Path.Combine(tempPatchFileDirectory, "LatestFileList.bin")); |
59 | 60 | var filesDiscovered = await latestFileListExtractor.ExtractStringsAsync(); |
60 | 61 |
|
61 | | - Console.WriteLine($"Discovered {filesDiscovered.Count} downloadable objects from the LatestFileList.bin file."); |
| 62 | + Log.Information("Discovered {FilesDiscoveredCount} downloadable objects from the LatestFileList.bin file.", |
| 63 | + filesDiscovered.Count); |
62 | 64 |
|
63 | 65 | var additionalFilesParser = new AdditionalFilesParser(Path.Combine(applicationDirectory, "AdditionalFiles.txt")); |
64 | 66 | var additionalFiles = await additionalFilesParser.GetAdditionalFilesAsync(); |
65 | 67 |
|
66 | | - Console.WriteLine($"Discovered {additionalFiles.Count} downloadable objects from the AdditionalFiles.txt file."); |
| 68 | + Log.Information("Discovered {AdditionalFilesCount} downloadable objects from the AdditionalFiles.txt file.", |
| 69 | + additionalFiles.Count); |
67 | 70 |
|
68 | 71 | var allFiles = new List<string>(); |
69 | 72 | allFiles.AddRange(filesDiscovered); |
|
72 | 75 | allFiles = allFiles.Distinct().ToList(); |
73 | 76 | allFiles.Sort(); |
74 | 77 |
|
75 | | - Console.WriteLine( |
76 | | - $"Discovered a total of {allFiles.Count} files to download after merging and removing duplicates."); |
| 78 | + Log.Information( |
| 79 | + "Discovered a total of {AllFilesCount} files to download after merging and removing duplicates.", |
| 80 | + allFiles.Count); |
77 | 81 |
|
78 | 82 | await directoryManipulator.OverrideLocalPackagesListAsync(allFiles); |
79 | 83 |
|
80 | | - Console.WriteLine( |
| 84 | + Log.Information( |
81 | 85 | "Deleted previously installed LocalPackagesList for a fresh installation and override with complete list."); |
82 | 86 |
|
83 | 87 | var currentFile = 1; |
84 | 88 | foreach (var file in allFiles) |
85 | 89 | { |
86 | | - Console.WriteLine($"[{currentFile:D4}/{allFiles.Count:D4}] BEGIN {file}"); |
| 90 | + Log.Information("[{CurrentFile:D4}/{AllFilesCount:D4}] BEGIN {File}", currentFile, allFiles.Count, file); |
87 | 91 |
|
88 | 92 | var fileSize = await patchClientDownloader.GetFileSizeAsync(file); |
89 | 93 |
|
90 | | - Console.WriteLine( |
91 | | - $"[{currentFile:D4}/{allFiles.Count:D4}] BEGIN {file} | File size: {fileSize / (1024.0 * 1024.0):F2}MB"); |
| 94 | + Log.Information( |
| 95 | + "[{CurrentFile:D4}/{AllFilesCount:D4}] BEGIN {File} | File size: {FileSize:F2}MB", currentFile, |
| 96 | + allFiles.Count, file, fileSize / (1024.0 * 1024.0)); |
92 | 97 |
|
93 | 98 | await patchClientDownloader.DownloadFileAsync(file, Path.Combine(installPath, "Data", "GameData")); |
94 | 99 |
|
95 | 100 | currentFile++; |
96 | 101 | } |
97 | 102 |
|
98 | | - Console.WriteLine( |
| 103 | + Log.Information( |
99 | 104 | "The files were successfully downloaded to the Wizard101 client. Please start up your game and enjoy!~"); |
100 | 105 | } |
101 | 106 | catch (Exception ex) |
|
0 commit comments