@@ -41,8 +41,7 @@ public async Task<UpdateResult> UpdateAsync(
4141
4242 try
4343 {
44- _logger . Information ( "Starting driver update for: {DriverName} v{Version}" ,
45- driverInfo . Name , driverInfo . Version ) ;
44+ _logger . Information ( $ "Starting driver update for: { driverInfo . Name } v{ driverInfo . Version } ") ;
4645
4746 result . StepLogs . Add ( $ "[{ DateTime . Now : HH:mm:ss} ] Starting driver update") ;
4847
@@ -78,7 +77,7 @@ public async Task<UpdateResult> UpdateAsync(
7877 if ( await BackupAsync ( driverInfo , backupPath , cancellationToken ) )
7978 {
8079 result . BackupPath = backupPath ;
81- _logger . Information ( "Backup created at: {BackupPath}" , backupPath ) ;
80+ _logger . Information ( $ "Backup created at: { backupPath } " ) ;
8281 }
8382 }
8483
@@ -161,8 +160,7 @@ public async Task<UpdateResult> UpdateAsync(
161160 finally
162161 {
163162 result . EndTime = DateTime . UtcNow ;
164- _logger . Information ( "Driver update process ended. Duration: {Duration}ms, Success: {Success}" ,
165- result . DurationMs , result . Success ) ;
163+ _logger . Information ( $ "Driver update process ended. Duration: { result . DurationMs } ms, Success: { result . Success } ") ;
166164 }
167165
168166 return result ;
@@ -171,7 +169,7 @@ public async Task<UpdateResult> UpdateAsync(
171169 /// <inheritdoc/>
172170 public async Task < bool > ValidateAsync ( DriverInfo driverInfo , CancellationToken cancellationToken = default )
173171 {
174- _logger . Information ( "Validating driver: {DriverName}" , driverInfo . Name ) ;
172+ _logger . Information ( $ "Validating driver: { driverInfo . Name } " ) ;
175173
176174 try
177175 {
@@ -241,7 +239,7 @@ public async Task<bool> RollbackAsync(string backupPath, CancellationToken cance
241239 {
242240 try
243241 {
244- _logger . Information ( "Rolling back driver from backup: {BackupPath}" , backupPath ) ;
242+ _logger . Information ( $ "Rolling back driver from backup: { backupPath } " ) ;
245243
246244 // Implement rollback logic
247245 // This involves:
@@ -258,11 +256,11 @@ public async Task<bool> RollbackAsync(string backupPath, CancellationToken cance
258256 var backupFiles = Directory . GetFiles ( backupPath , "*.*" , SearchOption . AllDirectories ) ;
259257 if ( ! backupFiles . Any ( ) )
260258 {
261- _logger . Warning ( "No backup files found in: {BackupPath}" , backupPath ) ;
259+ _logger . Warning ( $ "No backup files found in: { backupPath } " ) ;
262260 return false ;
263261 }
264262
265- _logger . Information ( "Found {Count } backup files" , backupFiles . Length ) ;
263+ _logger . Information ( $ "Found { backupFiles . Length } backup files") ;
266264
267265 // For INF-based drivers, try to reinstall the backed up version
268266 var infFiles = backupFiles . Where ( f => f . EndsWith ( ".inf" , StringComparison . OrdinalIgnoreCase ) ) . ToArray ( ) ;
@@ -273,7 +271,7 @@ public async Task<bool> RollbackAsync(string backupPath, CancellationToken cance
273271 {
274272 try
275273 {
276- _logger . Information ( "Attempting to restore driver from: {InfFile}" , infFile ) ;
274+ _logger . Information ( $ "Attempting to restore driver from: { infFile } " ) ;
277275 await InstallDriverUsingPnPUtilAsync ( infFile , cancellationToken ) ;
278276 }
279277 catch ( Exception ex )
@@ -301,7 +299,7 @@ private async Task ExecuteDriverInstallationAsync(
301299 UpdateStrategy strategy ,
302300 CancellationToken cancellationToken )
303301 {
304- _logger . Information ( "Executing driver installation: {DriverPath}" , driverInfo . FilePath ) ;
302+ _logger . Information ( $ "Executing driver installation: { driverInfo . FilePath } " ) ;
305303
306304 try
307305 {
@@ -328,7 +326,7 @@ private async Task ExecuteDriverInstallationAsync(
328326 /// </summary>
329327 private async Task InstallDriverUsingPnPUtilAsync ( string driverPath , CancellationToken cancellationToken )
330328 {
331- _logger . Information ( "Installing driver using PnPUtil: {DriverPath}" , driverPath ) ;
329+ _logger . Information ( $ "Installing driver using PnPUtil: { driverPath } " ) ;
332330
333331 var startInfo = new ProcessStartInfo
334332 {
@@ -348,7 +346,7 @@ private async Task InstallDriverUsingPnPUtilAsync(string driverPath, Cancellatio
348346
349347 await process . WaitForExitAsync ( cancellationToken ) ;
350348
351- _logger . Information ( "PnPUtil output: {Output}" , output ) ;
349+ _logger . Information ( $ "PnPUtil output: { output } " ) ;
352350
353351 if ( process . ExitCode != 0 )
354352 {
@@ -366,7 +364,7 @@ private async Task<bool> VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
366364 {
367365 try
368366 {
369- _logger . Information ( "Verifying driver installation for: {DriverPath}" , driverInfo . FilePath ) ;
367+ _logger . Information ( $ "Verifying driver installation for: { driverInfo . FilePath } " ) ;
370368
371369 // Use PnPUtil to enumerate installed drivers and check if our driver is present
372370 var processStartInfo = new ProcessStartInfo
@@ -394,7 +392,7 @@ private async Task<bool> VerifyDriverInstallationAsync(DriverInfo driverInfo, Ca
394392 bool isInstalled = output . Contains ( driverFileName , StringComparison . OrdinalIgnoreCase ) ||
395393 output . Contains ( Path . GetFileNameWithoutExtension ( driverInfo . FilePath ) , StringComparison . OrdinalIgnoreCase ) ;
396394
397- _logger . Information ( "Driver verification result: {IsInstalled}" , isInstalled ) ;
395+ _logger . Information ( $ "Driver verification result: { isInstalled } " ) ;
398396 return isInstalled ;
399397 }
400398 catch ( Exception ex )
@@ -467,19 +465,19 @@ public async Task<List<DriverInfo>> GetDriversFromDirectoryAsync(
467465
468466 try
469467 {
470- _logger . Information ( "Reading driver information from directory: {DirectoryPath}" , directoryPath ) ;
468+ _logger . Information ( $ "Reading driver information from directory: { directoryPath } " ) ;
471469
472470 if ( ! Directory . Exists ( directoryPath ) )
473471 {
474- _logger . Warning ( "Directory not found: {DirectoryPath}" , directoryPath ) ;
472+ _logger . Warning ( $ "Directory not found: { directoryPath } " ) ;
475473 return driverInfoList ;
476474 }
477475
478476 // Default to .inf files for Windows
479477 var pattern = searchPattern ?? "*.inf" ;
480478 var driverFiles = Directory . GetFiles ( directoryPath , pattern , SearchOption . AllDirectories ) ;
481479
482- _logger . Information ( "Found {Count } driver files matching pattern: {Pattern}" , driverFiles . Length , pattern ) ;
480+ _logger . Information ( $ "Found { driverFiles . Length } driver files matching pattern: { pattern } " ) ;
483481
484482 foreach ( var filePath in driverFiles )
485483 {
@@ -492,7 +490,7 @@ public async Task<List<DriverInfo>> GetDriversFromDirectoryAsync(
492490 if ( driverInfo != null )
493491 {
494492 driverInfoList . Add ( driverInfo ) ;
495- _logger . Information ( "Parsed driver: {DriverName } v{Version}" , driverInfo . Name , driverInfo . Version ) ;
493+ _logger . Information ( $ "Parsed driver: { driverInfo . Name } v{ driverInfo . Version } " ) ;
496494 }
497495 }
498496 catch ( Exception ex )
@@ -501,7 +499,7 @@ public async Task<List<DriverInfo>> GetDriversFromDirectoryAsync(
501499 }
502500 }
503501
504- _logger . Information ( "Successfully loaded {Count} driver(s) from directory" , driverInfoList . Count ) ;
502+ _logger . Information ( $ "Successfully loaded { driverInfoList . Count } driver(s) from directory") ;
505503 }
506504 catch ( Exception ex )
507505 {
@@ -573,9 +571,9 @@ public async Task<List<DriverInfo>> GetDriversFromDirectoryAsync(
573571 }
574572 }
575573 }
576- catch
574+ catch ( Exception ex )
577575 {
578- _logger . Debug ( $ "Could not get signature for file: { filePath } ") ;
576+ _logger . Debug ( $ "Could not get signature for file: { filePath } ", ex ) ;
579577 }
580578
581579 return driverInfo ;
@@ -645,9 +643,9 @@ private async Task ParseInfFileAsync(string infPath, DriverInfo driverInfo, Canc
645643 driverInfo . Version = "1.0.0" ;
646644 }
647645 }
648- catch
646+ catch ( Exception ex )
649647 {
650- _logger . Debug ( $ "Could not parse INF file: { infPath } ") ;
648+ _logger . Debug ( $ "Could not parse INF file: { infPath } ", ex ) ;
651649 }
652650 }
653651}
0 commit comments