From 0773b076a048cb92bd0c80efaf49f50cfa428f28 Mon Sep 17 00:00:00 2001 From: TinaMor Date: Tue, 20 May 2025 23:39:40 +0300 Subject: [PATCH 1/2] Use logger module for AllToolsUtilities.psm1 instead of Write-* commands --- .../Public/AllToolsUtilities.psm1 | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/containers-toolkit/Public/AllToolsUtilities.psm1 b/containers-toolkit/Public/AllToolsUtilities.psm1 index 9dc390c..afd732d 100644 --- a/containers-toolkit/Public/AllToolsUtilities.psm1 +++ b/containers-toolkit/Public/AllToolsUtilities.psm1 @@ -30,7 +30,7 @@ function Show-ContainerTools { $registerCommands = (Get-Command -Name "*-*Service" -Module 'Containers-Toolkit').Name -join ', ' $message = "For unregistered services/daemons, check the tool's help or register the service using `n`t$registerCommands" - Write-Information -MessageData $message -Tags "Instructions" -InformationAction Continue + [Logger]::Info($message) return $installedTools } @@ -89,10 +89,10 @@ function Install-ContainerTools { process { if ($PSCmdlet.ShouldProcess($env:COMPUTERNAME, $WhatIfMessage)) { - Write-Output "The following tools will be installed: $toInstallString" + [Logger]::Info("The following tools will be installed: $toInstallString") - Write-Debug "Downloading files to $DownloadPath" - Write-Debug "Installing files to $InstallPath" + [Logger]::Debug("Downloading files to $DownloadPath") + [Logger]::Debug("Installing files to $InstallPath") $completedInstalls = @() $failedInstalls = @() @@ -135,17 +135,17 @@ function Install-ContainerTools { $completedInstalls += $task.Name } catch { - Write-Error "$($task.Name) installation failed. $_" + [Logger]::Error("$($task.Name) installation failed. $_") $failedInstalls += $task.Name } } if ($completedInstalls) { - Write-Output "$($completedInstalls -join ', ') installed successfully.`n" + [Logger]::Info("$($completedInstalls -join ', ') installed successfully.`n") } if ($failedInstalls) { - Write-Warning "Installation failed for $($failedInstalls -join ', ')`n" + [Logger]::Warning("Installation failed for $($failedInstalls -join ', ')`n") } if ($RegisterServices) { @@ -153,7 +153,7 @@ function Install-ContainerTools { Initialize-NatNetwork -Force:$force -Confirm:$false } catch { - Write-Error "Failed to initialize NAT network. $_" + [Logger]::Error("Failed to initialize NAT network. $_") } } else { @@ -163,10 +163,10 @@ To register containerd and buildkitd services and create a NAT network, see help Get-Help Register-BuildkitdService Get-Help Initialize-NatNetwork "@ - Write-Information -MessageData $message -Tags "Instructions" -InformationAction Continue + [Logger]::Info($message) } - Write-Output "Installation complete. See logs for more details" + [Logger]::Info("Installation complete. See logs for more details") } else { # Code that should be processed if doing a WhatIf operation From d102394d0f6361b8e3cb905c7352d951f15ccdc6 Mon Sep 17 00:00:00 2001 From: Tina Murimi Date: Wed, 21 May 2025 16:44:19 +0300 Subject: [PATCH 2/2] Import logger modules --- containers-toolkit/Public/AllToolsUtilities.psm1 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/containers-toolkit/Public/AllToolsUtilities.psm1 b/containers-toolkit/Public/AllToolsUtilities.psm1 index afd732d..3c87a0f 100644 --- a/containers-toolkit/Public/AllToolsUtilities.psm1 +++ b/containers-toolkit/Public/AllToolsUtilities.psm1 @@ -7,6 +7,8 @@ ########################################################################### +using module "..\Private\logger.psm1" + $ModuleParentPath = Split-Path -Parent $PSScriptRoot Import-Module -Name "$ModuleParentPath\Private\CommonToolUtilities.psm1" -Force