Logger.ps1 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. function Log-Debug {
  2. [CmdletBinding()]
  3. param(
  4. [Parameter(Mandatory,ValueFromPipeline)]
  5. [ValidateNotNullOrEmpty()]
  6. [string[]] $Message
  7. )
  8. Process {
  9. foreach($m in $Message) {
  10. Write-Debug $m
  11. }
  12. }
  13. }
  14. function Log-Verbose {
  15. [CmdletBinding()]
  16. param(
  17. [Parameter(Mandatory,ValueFromPipeline)]
  18. [ValidateNotNullOrEmpty()]
  19. [string[]] $Message
  20. )
  21. Process {
  22. foreach($m in $Message) {
  23. Write-Verbose $m
  24. }
  25. }
  26. }
  27. function Log-Warning {
  28. [CmdletBinding()]
  29. param(
  30. [Parameter(Mandatory,ValueFromPipeline)]
  31. [ValidateNotNullOrEmpty()]
  32. [string[]] $Message
  33. )
  34. Process {
  35. foreach($m in $Message) {
  36. Write-Warning $m
  37. }
  38. }
  39. }
  40. function Log-Error {
  41. [CmdletBinding()]
  42. param(
  43. [Parameter(Mandatory,ValueFromPipeline)]
  44. [ValidateNotNullOrEmpty()]
  45. [string[]] $Message
  46. )
  47. Process {
  48. foreach($m in $Message) {
  49. Write-Error $m
  50. }
  51. }
  52. }
  53. function Log-Information {
  54. [CmdletBinding()]
  55. param(
  56. [Parameter(Mandatory,ValueFromPipeline)]
  57. [ValidateNotNullOrEmpty()]
  58. [string[]] $Message
  59. )
  60. Process {
  61. if ( ! ( $script:Quiet ) ) {
  62. $StageName = $( if ( $script:StageName -ne $null ) { $script:StageName } else { '' })
  63. $Icon = ' =>'
  64. foreach($m in $Message) {
  65. Write-Host -NoNewLine -ForegroundColor Blue " ${StageName} $($Icon.PadRight(5)) "
  66. Write-Host "${m}"
  67. }
  68. }
  69. }
  70. }
  71. function Log-Status {
  72. [CmdletBinding()]
  73. param(
  74. [Parameter(Mandatory,ValueFromPipeline)]
  75. [ValidateNotNullOrEmpty()]
  76. [string[]] $Message
  77. )
  78. Process {
  79. if ( ! ( $script:Quiet ) ) {
  80. $StageName = $( if ( $StageName -ne $null ) { $StageName } else { '' })
  81. $Icon = ' >'
  82. foreach($m in $Message) {
  83. Write-Host -NoNewLine -ForegroundColor Green " ${StageName} $($Icon.PadRight(5)) "
  84. Write-Host "${m}"
  85. }
  86. }
  87. }
  88. }
  89. function Log-Output {
  90. [CmdletBinding()]
  91. param(
  92. [Parameter(Mandatory,ValueFromPipeline)]
  93. [ValidateNotNullOrEmpty()]
  94. [string[]] $Message
  95. )
  96. Process {
  97. if ( ! ( $script:Quiet ) ) {
  98. $StageName = $( if ( $script:StageName -ne $null ) { $script:StageName } else { '' })
  99. $Icon = ''
  100. foreach($m in $Message) {
  101. Write-Output " ${StageName} $($Icon.PadRight(5)) ${m}"
  102. }
  103. }
  104. }
  105. }
  106. $Columns = (Get-Host).UI.RawUI.WindowSize.Width - 5