Native support for destructuring F# types when logging to Serilog.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
assets
src/Destructurama.FSharp
.gitattributes
.gitignore
Build.ps1
CHANGES.md
LICENSE
README.md
destructurama-fsharp.sln

README.md

Destructurama.FSharp

Build status

Native support for destructuring F# types when logging to Serilog.

Discriminated unions like:

type Shape =
    | Circle of Radius : double
    | Rectangle of Width : double *  Height : double
    | Arc // ...
let shape = Circle 5.

When logged with Serilog:

Log.Information("Drawing a {@Shape}", shape)

Are printed nicely like:

2015-01-14 16:58:31 [Information] Drawing a Circle { Radius: 5 }

Depending on the log storage you use you’ll be able to query on the tag as well as the fields (like Radius) from the union.

Enabling the package

You can enable this by installing the package from NuGet:

Install-Package Destructurama.FSharp

and adding Destructure.FSharpTypes() to your logger configuration:

open Serilog

[<EntryPoint>]
let main argv = 

    Log.Logger <- LoggerConfiguration()
        .Destructure.FSharpTypes()
        .WriteTo.ColoredConsole()
        .CreateLogger()

    Log.Information("Drawing a {@Shape}", Circle 5.)

    0