From 09bea282a01fe403edcaf52c2256cbdacd362819 Mon Sep 17 00:00:00 2001 From: DennisL68 Date: Thu, 25 May 2023 13:54:42 +0200 Subject: [PATCH 1/2] refact: Replaced Write-Host with Out-Host https://learn.microsoft.com/en-us/powershell/utility-modules/psscriptanalyzer/rules/avoidusingwritehost?view=ps-modules --- PrometheusExporter/PrometheusExporter.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PrometheusExporter/PrometheusExporter.psm1 b/PrometheusExporter/PrometheusExporter.psm1 index 5e4971c..2525c09 100644 --- a/PrometheusExporter/PrometheusExporter.psm1 +++ b/PrometheusExporter/PrometheusExporter.psm1 @@ -147,7 +147,7 @@ class Exporter { $PromResponse = $this.Collect() $Response.AddHeader("Content-Type", "text/plain; version=0.0.4; charset=utf-8") } catch { - write-host $_ + $_ | Out-Host $Response.StatusCode = 500 $PromResponse = 'Internal Server Error' } @@ -181,7 +181,7 @@ class Exporter { } function New-LogMessage([String] $Msg) { - Write-Host "$(Get-Date -Format o) $Msg" + "$(Get-Date -Format o) $Msg" | Out-Host } function New-MetricDescriptor( From 8e83a507010cbf21fbf2690c4f5a4f400b4fecde Mon Sep 17 00:00:00 2001 From: DennisL68 Date: Tue, 10 Oct 2023 16:04:06 +0200 Subject: [PATCH 2/2] fix: Changed Write-Host to Write-Output --- PrometheusExporter/PrometheusExporter.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PrometheusExporter/PrometheusExporter.psm1 b/PrometheusExporter/PrometheusExporter.psm1 index 2525c09..915f5fb 100644 --- a/PrometheusExporter/PrometheusExporter.psm1 +++ b/PrometheusExporter/PrometheusExporter.psm1 @@ -147,7 +147,7 @@ class Exporter { $PromResponse = $this.Collect() $Response.AddHeader("Content-Type", "text/plain; version=0.0.4; charset=utf-8") } catch { - $_ | Out-Host + Write-Output $_ $Response.StatusCode = 500 $PromResponse = 'Internal Server Error' } @@ -181,7 +181,7 @@ class Exporter { } function New-LogMessage([String] $Msg) { - "$(Get-Date -Format o) $Msg" | Out-Host + Write-Output "$(Get-Date -Format o) $Msg" } function New-MetricDescriptor(