From 2c0ab635d5550976c157eb5c5eccc4688fa6efad Mon Sep 17 00:00:00 2001 From: Chidozie Ononiwu Date: Tue, 8 Sep 2020 17:24:59 -0700 Subject: [PATCH] Add Logging commands to common location --- eng/common/scripts/common.ps1 | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/common.ps1 b/eng/common/scripts/common.ps1 index 6a1f1487832..e73654cd106 100644 --- a/eng/common/scripts/common.ps1 +++ b/eng/common/scripts/common.ps1 @@ -20,12 +20,43 @@ $EngScriptsLanguageSettings = Join-path $EngScriptsDir "Language-Settings.ps1" if (Test-Path $EngScriptsLanguageSettings) { . $EngScriptsLanguageSettings } -If ($LanguageShort -eq $null) +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" \ No newline at end of file +$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