NorthWestNodes.Common 0.4.5

Suggested Alternatives

Web349.Logging

Additional Details

The Datadog logger within Northwest Nodes LLC-FZ has been discontinued and migrated to Web349.Logging

There is a newer version of this package available.
See the version list below for details.
dotnet add package NorthWestNodes.Common --version 0.4.5
NuGet\Install-Package NorthWestNodes.Common -Version 0.4.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NorthWestNodes.Common" Version="0.4.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NorthWestNodes.Common --version 0.4.5
#r "nuget: NorthWestNodes.Common, 0.4.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NorthWestNodes.Common as a Cake Addin
#addin nuget:?package=NorthWestNodes.Common&version=0.4.5

// Install NorthWestNodes.Common as a Cake Tool
#tool nuget:?package=NorthWestNodes.Common&version=0.4.5

NorthWest Nodes common library

Nuget

The NorthWest Nodes Common Library is a class library written in C# using the .NET Core 7.0 framework. It contains several common functions used throughout the closed- and open-source projects at NorthWest Nodes (https://northwestnodes.com).

One of its main features is a highly flexible Datadog logger.

Installation

  • Install-Package NorthWestNodes.Common
  • dotnet add package NorthWestNodes.Common

Datadog logger

Configuration

Namespaces:

  • NorthWestNodes.Common.Logging
  • NorthWestNodes.Common.Logging.Datadog

Environment variables:

  • DD_API_KEY: the API key for your Datadog app
  • DD_HOST: the Host column in Datadog
  • DD_SERVICE: the Service column in Datadog
  • DD_SOURCE: the Source column in Datadog

Usage examples

Send a basic Datadog log event:

Log log = DDLog.Create();
log.WriteInfo("An INFO log event message appearing in Datadog's message column");

Dynamic enrichtments

Send a Datadog log event with a dynamic enrichment. Dynamic enrichments get removed/reset after each Write operation:

Stopwatch sw = Stopwatch.StartNew();
// do a thing
sw.Stop();

Log log = DDLog.Create();
log
    .EnrichDynamic("responseTime", sw.ElapsedMilliseconds)
    .WriteInfo("An INFO log event message appearing in Datadog's message column");

Static enrichments

Send a Datadog log event with a static enrichment. Static enrichments do not get removed after each Write operation. Can be used in combination with Dynamic enrichtments:

Log log = DDLog.Create();
log.EnrichStatic("network", "source-network");

log
    .EnrichDynamic("someField", someVariable)
    .WriteInfo("An INFO log event message appearing in Datadog's message column");

Log levels

You can set the log level and calling the appropriate Write*** function will log messages accordingly:

Log log = DDLog.Create();
log.SetLogLevel(LogLevel.Error); // only errors and up
log.WriteInfo("Hello world"); // will NOT be processed
log.WriteFatal("Ack, mein leben!"); // will be processed

Log event dispatching

The Datadog logger uses a background Task to dispatch log events in batches. By default a batch contains a maximum of 10 log events and each a maximum age of 5 seconds before being forcibly dispatched regardless of how many items a batch contains.

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.5.0 394 2/19/2023
0.4.5 242 2/19/2023
0.4.4 255 2/17/2023
0.4.3 239 2/17/2023
0.4.2 242 2/17/2023
0.4.1 246 2/17/2023
0.4.0 236 2/17/2023
0.4.0-beta1 128 2/17/2023
0.3.1-beta1 143 9/30/2022
0.2.4-beta1 144 8/17/2022
0.2.3-beta1 145 8/17/2022
0.2.1-beta1 142 8/17/2022
0.2.0-beta1 144 8/15/2022
0.1.2-beta1 130 8/15/2022
0.1.1-beta1 140 8/15/2022
0.1.0-beta1 143 8/12/2022