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 12, 2020
1 parent 5ed29c9 commit 5664caa
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 33 deletions.
36 changes: 3 additions & 33 deletions eng/common/scripts/common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -20,43 +21,12 @@ $EngScriptsLanguageSettings = Join-path $EngScriptsDir "Language-Settings.ps1"
if (Test-Path $EngScriptsLanguageSettings) {
. $EngScriptsLanguageSettings
}
if ($null -eq $LanguageShort)
if (-not $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 (-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"
}
}

0 comments on commit 5664caa

Please sign in to comment.