PS Standard.ps1

From vwiki
Jump to navigation Jump to search
# ======================================================
# Standard include library (logging etc)
# ======================================================
# Simon Strutt        Nov 2010
# ======================================================
#
# Version 1
# - Initial Creation
#
# Version 2
# - Added error logger
#
# ======================================================

$RGB_RED = "#ff3300"
$RGB_AMBER = "#ff9900"
$RGB_GREEN = "#66ff99"

function Log ($text) {
    [int]$duration = (New-TimeSpan $start (Get-Date)).TotalSeconds
    Write-Host "$duration secs | $text"
}

function Log-NoNewLine ($text) {
    [int]$duration = (New-TimeSpan $start (Get-Date)).TotalSeconds
    Write-Host "$duration secs | $text" -nonewline
}

#function Log-Error($text) {
#    if (!$ErrorLog) {
#        $ErrorLog = @()
#    }
#    $ErrorLog += $text
#    Log ("ERROR: " + $text)
#}