Destructurama.FSharp.NetCore

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


Keywords
fsharp, serilog
License
Apache-2.0
Install
Install-Package Destructurama.FSharp.NetCore -Version 1.0.14

Documentation

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