Created
September 26, 2013 12:57
-
-
Save andrewconnell/6713788 to your computer and use it in GitHub Desktop.
Standardized logger library for PowerShell scripts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= | |
# Script: Logger.ps1 | |
# | |
# Author: Andrew Connell | |
# http://www.AndrewConnell.com | |
# | |
# Description: Standardized logging library. | |
# | |
# =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= | |
# GLOBAL CONSTANTS | |
$PRELUDE_INFO = "INFO :" | |
$PRELUDE_WARNING = "WARNING :" | |
$PRELUDE_ERROR = "ERROR :" | |
$PRELUDE_HIGHLIGHT = "HIGHLIGHT :" | |
$PRELUDE_SUCCESS = "SUCCESS :" | |
$FORECOLOR_INFO = "Gray" | |
$FORECOLOR_WARNING = "Yellow" | |
$FORECOLOR_ERROR = "Red" | |
$FORECOLOR_HIGHLIGHT = "White" | |
$FORECOLOR_SUCCESS = "Green" | |
# --------------------------------------------------------- | |
function LogSection($title){ | |
Write-Host | |
Write-Host $title -ForegroundColor Black -BackgroundColor White | |
} | |
function LogWrite($prelude, $message, $color){ | |
Write-Host $prelude $message -ForegroundColor $color | |
} | |
function LogInfo($message){ | |
LogWrite $PRELUDE_INFO $message $FORECOLOR_INFO | |
} | |
function LogWarning($message){ | |
LogWrite $PRELUDE_WARNING $message $FORECOLOR_WARNING | |
} | |
function LogError($message){ | |
LogWrite $PRELUDE_ERROR $message $FORECOLOR_ERROR | |
} | |
function LogHighlight($message){ | |
LogWrite $PRELUDE_HIGHLIGHT $message $FORECOLOR_HIGHLIGHT | |
} | |
function LogSuccess($message){ | |
LogWrite $PRELUDE_SUCCESS $message $FORECOLOR_SUCCESS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment