Skip to content

Commit

Permalink
Move logging into its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Sep 11, 2020
1 parent 19c0af1 commit 7f2993e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 32 deletions.
33 changes: 1 addition & 32 deletions eng/common/scripts/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
$PublishGithubIODocsFn = "Publish-${Language}-GithubIODocs"
40 changes: 40 additions & 0 deletions eng/common/scripts/logging.ps1
Original file line number Diff line number Diff line change
@@ -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"
}
}

0 comments on commit 7f2993e

Please sign in to comment.