From 7f2993eec7e917933e01969e0dfe150ec5e21302 Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Thu, 10 Sep 2020 17:02:04 -0700 Subject: [PATCH] Move logging into its own file --- eng/common/scripts/common.ps1 | 33 +--------------------------- eng/common/scripts/logging.ps1 | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 32 deletions(-) create mode 100644 eng/common/scripts/logging.ps1 diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index e73654cd1065..7709af7031d4 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -24,39 +24,8 @@ if ($null -eq $LanguageShort) { $LangaugeShort = $Language } -if ($null -eq $isDevOpsRun) -{ - $isDevOpsRun = ($null -ne $env:SYSTEM_TEAMPROJECTID) -} # Transformed Functions $GetPackageInfoFromRepoFn = "Get-${Language}-PackageInfoFromRepo" $GetPackageInfoFromPackageFileFn = "Get-${Language}-PackageInfoFromPackageFile" -$PublishGithubIODocsFn = "Publish-${Language}-GithubIODocs" - -function LogHelper ($logType, $logArgs) -{ - if ($isDevOpsRun) - { - Write-Host "##vso[task.LogIssue type=$logType;]$logArgs" - } - else - { - Write-Warning "$logArgs" - } -} - -function LogWarning -{ - LogHelper -logType "warning" -logArgs $args -} - -function LogError -{ - LogHelper -logType "error" -logArgs $args -} - -function LogDebug -{ - LogHelper -logType "debug" -logArgs $args -} \ No newline at end of file +$PublishGithubIODocsFn = "Publish-${Language}-GithubIODocs" \ No newline at end of file diff --git a/eng/common/scripts/logging.ps1 b/eng/common/scripts/logging.ps1 new file mode 100644 index 000000000000..b8eb2296f325 --- /dev/null +++ b/eng/common/scripts/logging.ps1 @@ -0,0 +1,40 @@ +if ($null -eq $isDevOpsRun) +{ + $isDevOpsRun = ($null -ne $env:SYSTEM_TEAMPROJECTID) +} + +function LogWarning +{ + if ($isDevOpsRun) + { + Write-Host "##vso[task.LogIssue type=warning;]$args" + } + else + { + Write-Warning "$args" + } +} + +function LogError +{ + if ($isDevOpsRun) + { + Write-Host "##vso[task.LogIssue type=error;]$args" + } + else + { + Write-Error "$args" + } +} + +function LogDebug +{ + if ($isDevOpsRun) + { + Write-Host "##vso[task.LogIssue type=debug;]$args" + } + else + { + Write-Debug "$args" + } +} \ No newline at end of file