From c0780afbbd043fbb692e72eb2485c998d58e5c9e Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Wed, 16 Sep 2020 04:24:20 +0000 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools repository for Tools PR 974 --- eng/common/scripts/common.ps1 | 3 ++- eng/common/scripts/logging.ps1 | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 eng/common/scripts/logging.ps1 diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index 6a1f1487832ba..4caaacc4e2cfe 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -8,6 +8,7 @@ $EngScriptsDir = Join-Path $EngDir "scripts" . (Join-Path $EngCommonScriptsDir SemVer.ps1) . (Join-Path $EngCommonScriptsDir ChangeLog-Operations.ps1) . (Join-Path $EngCommonScriptsDir Package-Properties.ps1) +. (Join-Path $EngCommonScriptsDir logging.ps1) # Setting expected from common languages settings $Language = "Unknown" @@ -20,7 +21,7 @@ $EngScriptsLanguageSettings = Join-path $EngScriptsDir "Language-Settings.ps1" if (Test-Path $EngScriptsLanguageSettings) { . $EngScriptsLanguageSettings } -If ($LanguageShort -eq $null) +if (-not $LanguageShort) { $LangaugeShort = $Language } diff --git a/eng/common/scripts/logging.ps1 b/eng/common/scripts/logging.ps1 new file mode 100644 index 0000000000000..19a6fa5bc36d8 --- /dev/null +++ b/eng/common/scripts/logging.ps1 @@ -0,0 +1,40 @@ +if (-not $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