Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Standardized logger library for PowerShell scripts.
# =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# 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
You can’t perform that action at this time.