Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/samerde/write-this
A little function to help write output to the console and log files at the same time to keep your actual code cleaner.
https://github.com/samerde/write-this
powershell utilities utility-function
Last synced: 26 days ago
JSON representation
A little function to help write output to the console and log files at the same time to keep your actual code cleaner.
- Host: GitHub
- URL: https://github.com/samerde/write-this
- Owner: SamErde
- License: mit
- Created: 2024-08-04T13:10:24.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-07T13:45:30.000Z (about 1 month ago)
- Last Synced: 2024-10-13T00:01:39.915Z (26 days ago)
- Topics: powershell, utilities, utility-function
- Language: PowerShell
- Homepage:
- Size: 40 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Roadmap: ROADMAP.md
Awesome Lists containing this project
README
# Write-This
[![GitHub stars](https://img.shields.io/github/stars/samerde/Write-This?cacheSeconds=3600)](https://github.com/samerde/Write-This/stargazers/)
[![GitHub contributors](https://img.shields.io/github/contributors/samerde/Write-This.svg)](https://github.com/samerde/Write-This/graphs/contributors/)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)![GitHub top language](https://img.shields.io/github/languages/top/SamErde/Write-This)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ae92f0d929de494690e712b68fb3b52c)](https://app.codacy.com/gh/SamErde/Write-This/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)## Synopsis
Write a message to the console and a log file at the same time.
## Description
A little function to help write output to the console and log files at the same time to keep your actual code cleaner. Instead of having separate lines for interactive output and log files, one function can handle both.
## Example
Until this is an actual module, the following example shows how to manually import the three scripts and use them:
```powershell
. .\Start-WriteThis.ps1
. .\Write-This.ps1
. .\Stop-WriteThis.ps1Start-WriteThis -LogFile "TestLog"
Write-This -LogText "First!" -Output Both -ForegroundColor White -BackgroundColor DarkBlue
$Directories = Get-ChildItem -Directory $env:TEMP
$DirectoryCount = $Directories.Count
Write-This -LogText "Found $DirectoryCount directories in the current folder." -Output Both
Write-This -LogText "These details are only going into the log file:`n$Directories" -Output LogOnly
Write-This -LogText "Let's finish this up." -ForegroundColor Green -BackgroundColor BlackStop-WriteThis -LogFile $script:LogFile
```