Skip to content

Instantly share code, notes, and snippets.

@andrewconnell
Created September 26, 2013 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewconnell/6713788 to your computer and use it in GitHub Desktop.
Save andrewconnell/6713788 to your computer and use it in GitHub Desktop.
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