Coder Social home page Coder Social logo
 photo

poshlog Goto Github PK

repos: 11.0 gists: 0.0

Type: Organization

Bio: PoShLog is powershell cross-platform logging module. PoShLog allows you to log structured event data into console, file and much more places easily.

icon

PoShLog

psgallery psgallery Discord Build Status Support

Serilog for powershell

PoShLog is powershell cross-platform logging module. PoShLog allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog.

Key Features

  • Structured log event data
  • Clean and easy to use API
  • Cross-platform
  • Easily extensible

Getting started

If you are familiar with PowerShell, skip to Installation section. For more detailed installation instructions check out Getting started wiki.

Installation

To install PoShLog, run following snippet from powershell:

Install-Module PoShLog

Usage

Setup logger using pipeline fluent API and write some log messages(in this case into file and console):

Import-Module PoShLog

# Create new logger
# This is where you customize, when and how to log
New-Logger |
    Set-MinimumLevel -Value Verbose | # You can change this value later to filter log messages
    # Here you can add as many sinks as you want - see https://github.com/PoShLog/PoShLog/wiki/Sinks for all available sinks
    Add-SinkConsole |   # Tell logger to write log messages to console
    Add-SinkFile -Path 'C:\Data\my_awesome.log' | # Tell logger to write log messages into file
    Start-Logger

# Test all log levels
Write-VerboseLog 'Test verbose message'
Write-DebugLog 'Test debug message'
Write-InfoLog 'Test info message'
Write-WarningLog 'Test warning message'
Write-ErrorLog 'Test error message'
Write-FatalLog 'Test fatal message'

Close-Logger

poshlog_example_fullversion

For detailed documentation see wiki

You can(and you should) log formatted data:

Write-InfoLog 'Current date and time is {DateTime}' -PropertyValues (Get-Date)

# Some example data
$position = @{
    Latitude = 25
    Longitude = 134
}
$elapsedMs = 34

Write-InfoLog 'Processed {@Position} in {Elapsed:000} ms.' -PropertyValues $position, $elapsedMs

poshlog_example_simplest_console

Fluent API is too bulky? You don't need extra sinks? Use short setup version(logs into console and file):

# Create and start new logger
Start-Logger -FilePath 'C:\Data\my_awesome.log' -Console

Write-InfoLog 'Hurrray, my first log message!'

# Don't forget to close the logger
Close-Logger

poshlog_example_simplest_console

Extendability

PoShLog is extensible just like Serilog. All available extensions can be found here.

Documentation

These examples are just to get you started fast. For more detailed documentation please check wiki.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Show your support

  • ⭐ Star the PoShLog repository. This is the least you can do to support this project.
  • πŸ‘ Give us some feedback or suggest features using Discussions or discord
  • πŸ”Ž Test PoShLog and raise issues
  • Contribute πŸš€ you can start with good first issues

Contributors

Building Locally

  1. Install PoShLog.Tools

     Install-Module -Name PoShLog.Tools -Force -Verbose -Scope CurrentUser
    
  2. Import PoShLog.Tools

     Import-Module -Name PoShLog.Tools
    
  3. Bootstrap the required modules

     Bootstrap '.\cd\RequiredModules.psd1'
    
  4. Run the build script

     Invoke-Build '.\src\PoShLog.Build.ps1' -Configuration '(Dev/Prod)' -Task Clean, BuildDependencies, CopyModuleFiles -ModuleVersion "$(MajorVersion).$(MinorVersion).$(BugfixVersion)"
    

Authors

Release Notes

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

poshlog's Projects

poshlog icon poshlog

:nut_and_bolt: PoShLog is PowerShell cross-platform logging module. It allows you to log structured event data into console, file and much more places easily. It's built upon great C# logging library Serilog - https://serilog.net/

poshlog.enrichers icon poshlog.enrichers

Extension module for PoShLog logging module. Contains lot of helpful enricher methods, useful when enriching log messages with more properties.

poshlog.sinks.mssqlserver icon poshlog.sinks.mssqlserver

Extension module for PoShLog logging module. It contains a sink that writes log messages into MSSql database.

poshlog.sinks.notepad icon poshlog.sinks.notepad

Extension module for PoShLog logging module. It contains a sink that writes log messages into Notepad.

poshlog.sinks.seq icon poshlog.sinks.seq

Extension module for PoShLog logging module. It contains a sink that writes log messages to Seq server.

poshlog.sinks.syslog icon poshlog.sinks.syslog

Extension module for PoShLog logging module. It contains a sink that publishes log messages to syslog servers.

poshlog.tools icon poshlog.tools

Additional tools for building PoShLog logging module and its extension modules

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.