Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 40 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<p align="center">
A simple project to easily add a log to your projects
<br />
<a href="https://github.com/captainqwerty/Write-Log/releases">Releases</a> -
<a href="https://github.com/captainqwerty/Write-Log/issues">Report Bug</a>
<a href="https://github.com/PowershellGroup/Write-Log-Module/releases">Releases</a> -
<a href="https://github.com/PowershellGroup/Write-Log-Module/issues">Report Bug</a>
</p>
</div>

Expand All @@ -26,11 +26,11 @@ This project was to just offer people a easy way to quickly add the ability to o

### Class Version

The class Version is the preffered version however this version is limited to PowerShell Version 5.0 and greater and utilises the *Using* statement.
The class Version is the preferred version however this version is limited to PowerShell Version 5.0 and greater and utilizes the *Using* statement.

### Module Version

The Module Version is available for those prefering to use *Import-Module* and those using older versions of PowerShell as the Class version will not work on PowerShell versions prior to 5.0.
The Module Version is available for those preferring to use *Import-Module* and those using older versions of PowerShell as the Class version will not work on PowerShell versions prior to 5.0.

<p align="right">(<a href="#top">back to top</a>)</p>

Expand All @@ -43,36 +43,42 @@ To get a local copy up and running follow these simple example steps.
### Prerequisites

This is an example of how to list things you need to use the software and how to install them.

* PowerShell version 2.0 or greater - Module Version.
* PowerShell version 5.0 or greater - Either version.

### Installation of Class Version

1. Download the <a href="https://github.com/captainqwerty/Write-Log/release">latest release</a>.
1. Download the <a href="https://github.com/PowershellGroup/Write-Log-Module/release">latest release</a>.
2. Extract the zipped folder.
3. Place the "Write-Log" folder in your project's folder or in a location the script can access under the context it will be ran.
4. Add the Using satement pointing to the Write-Log-Class.psm1 file, please note using statements must be the very first lines of your script. In this example the Write-Log folder containing the file is in the root folder with the script calling it.
4. Add the Using statement pointing to the Write-Log-Class.psm1 file, please note using statements must be the very first lines of your script. In this example the Write-Log folder containing the file is in the root folder with the script calling it.

```ps1
using module ".\Write-Log\Write-Log-Class.psm1"
```
4. See <a href="#usage-of-the-class-version">Class Version Usage</a> section for examples on how to configure the log location and add enteries.

1. See <a href="#usage-of-the-class-version">Class Version Usage</a> section for examples on how to configure the log location and add entries.

### Installation of Module Version

1. Download the <a href="https://github.com/captainqwerty/Write-Log/releases">latest release</a>.
1. Download the <a href="https://github.com/PowershellGroup/Write-Log-Module/releases">latest release</a>.
2. Extra the zipped folder.
3. Ensure the Write-log.psm1 remains in a folder called "Write-Log" and place the Write-Log folder in your project's folder or in a location the script can access under the context it will be ran.
4. Import the Module. In this example the Write-Log folder is in the root of the project folder.
4. Import the Module. In this example the Write-Log folder is in the root of the project folder.

```ps1
$module = "$psscriptroot\Write-Log"
$module = "$PSScriptRoot\Write-Log"
if(!(test-path $module)){
write-host "$module not found" -ForegroundColor Red
exit
}
Import-Module $module
```
4. See <a href="#usage-of-the-module-version">Module Version Usage</a> section for examples on how to configure the log location and add enteries.
5. Add the Remove-Module line to the bottom of your script.

1. See <a href="#usage-of-the-module-version">Module Version Usage</a> section for examples on how to configure the log location and add entries.
2. Add the Remove-Module line to the bottom of your script.

```ps1
Remove-Module Write-Log
```
Expand All @@ -81,17 +87,19 @@ Remove-Module Write-Log

<!-- USAGE EXAMPLES -->
## Usage of the Class Version

```ps1
using module ".\Class\Write-Log\Write-Log-Class.psm1"

$Log = [WriteLog]::New("C:\Example\mylog.log")

$Log.AddInfo("Something occured that was wroth making an info log about")
$Log.AddInfo("Something occurred that was worth making an info log about")
$Log.AddError("There was a huge error!")
$Log.AddWarning("Oh dear I should really warn you about this!")
$Log.AddWarning("Oh dear, I should really warn you about this!")
$Log.AddEntry("Testing","Test Severity") #This method is hidden but can be used for custom severities
```
The below example shows having mutliple Write-Log objects to store different types or log enteries in different logs.

The below example shows having multiple Write-Log objects to store different types or log entries in different logs.

```ps1
using module ".\Class\Write-Log\Write-Log-Class.psm1"
Expand All @@ -100,14 +108,15 @@ $InfoLog = [WriteLog]::New("C:\Example\Info.log")
$ErrorLog = [WriteLog]::New("C:\Example\Errors.log")
$WarningLog = [WriteLog]::New("C:\Example\Warning.log")

$InfoLog.AddInfo("Something occured that was wroth making an info log about")
$InfoLog.AddInfo("Something occurred that was worth making an info log about")
$ErrorLog.AddError("There was a huge error!")
$WarningLog.AddWarning("Oh dear I should really warn you about this!")
$WarningLog.AddWarning("Oh dear, I should really warn you about this!")
```

## Usage of the Module version

```ps1
$module = "$psscriptroot\Module\Write-Log"
$module = "$PSScriptRoot\Module\Write-Log"
if(!(test-path $module)){
write-host "$module not found" -ForegroundColor Red
exit
Expand All @@ -122,9 +131,11 @@ write-log "This is an example Warning" -severity "Warning" -logLocation $logLoca

Remove-Module Write-Log
```
Below is an example of having seperate logs for Info, Error and Warning enteries.

Below is an example of having separate logs for Info, Error and Warning entries.

```ps1
$module = "$psscriptroot\Module\Write-Log"
$module = "$PSScriptRoot\Module\Write-Log"
if(!(test-path $module)){
write-host "$module not found" -ForegroundColor Red
exit
Expand All @@ -141,6 +152,7 @@ write-log "This is an example Warning" -severity "Warning" -logLocation $Warning

Remove-Module Write-Log
```

<p align="right">(<a href="#top">back to top</a>)</p>

<!-- CONTRIBUTING -->
Expand Down Expand Up @@ -168,13 +180,13 @@ Don't forget to give the project a star! Thanks again!

<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/captainqwerty/Write-Log.svg?style=for-the-badge
[contributors-url]: https://github.com/captainqwerty/Write-Log/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/captainqwerty/Write-Log.svg?style=for-the-badge
[forks-url]: https://github.com/captainqwerty/Write-Log/network/members
[stars-shield]: https://img.shields.io/github/stars/captainqwerty/Write-Log.svg?style=for-the-badge
[stars-url]: https://github.com/captainqwerty/Write-Log/stargazers
[issues-shield]: https://img.shields.io/github/issues/captainqwerty/Write-Log.svg?style=for-the-badge
[issues-url]: https://github.com/captainqwerty/Write-Log/issues
[contributors-shield]: https://img.shields.io/github/contributors/PowershellGroup/Write-Log-Module.svg?style=for-the-badge
[contributors-url]: https://github.com/PowershellGroup/Write-Log-Module/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/PowershellGroup/Write-Log-Module.svg?style=for-the-badge
[forks-url]: https://github.com/PowershellGroup/Write-Log-Module/network/members
[stars-shield]: https://img.shields.io/github/stars/PowershellGroup/Write-Log-Module.svg?style=for-the-badge
[stars-url]: https://github.com/PowershellGroup/Write-Log-Module/stargazers
[issues-shield]: https://img.shields.io/github/issues/PowershellGroup/Write-Log-Module.svg?style=for-the-badge
[issues-url]: https://github.com/PowershellGroup/Write-Log-Module/issues
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://www.linkedin.com/in/antonybragg/