OwlCore.Diagnostics 0.0.0

dotnet add package OwlCore.Diagnostics --version 0.0.0                
NuGet\Install-Package OwlCore.Diagnostics -Version 0.0.0                
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="OwlCore.Diagnostics" Version="0.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OwlCore.Diagnostics --version 0.0.0                
#r "nuget: OwlCore.Diagnostics, 0.0.0"                
#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 OwlCore.Diagnostics as a Cake Addin
#addin nuget:?package=OwlCore.Diagnostics&version=0.0.0

// Install OwlCore.Diagnostics as a Cake Tool
#tool nuget:?package=OwlCore.Diagnostics&version=0.0.0                

OwlCore.Diagnostics Version

Supplemental diagnostic tooling for dotnet.

Featuring:

  • A simple static Logger for consolidating outputting one or more log streams.
  • ProcessHelpers for interacting with executable binaries.

Install

Published releases are available on NuGet. To install, run the following command in the Package Manager Console.

PM> Install-Package OwlCore.Diagnostics

Or using dotnet

> dotnet add package OwlCore.Diagnostics

Usage

Logger

var startTime = DateTime.Now;

// Logging output routing //
////////////////////////////
Logger.MessageReceived += Logger_MessageReceived;

void Logger_MessageReceived(object? sender, LoggerMessageEventArgs e) => Console.WriteLine(FormatLoggerMessage(e));
void Logger_MessageReceived(object? sender, LoggerMessageEventArgs e) => Debug.WriteLine(FormatLoggerMessage(e));

string FormatLoggerMessage(LoggerMessageEventArgs e) => $"+{Math.Round((DateTime.Now - startTime).TotalMilliseconds)}ms {Path.GetFileNameWithoutExtension(e.CallerFilePath)} {e.CallerMemberName}  [{e.Level}] {e.Exception} {e.Message}";

// Additional logging input routing //
//////////////////////////////////////
// Normal unhandled application exceptions
AppDomain.CurrentDomain.UnhandledException += (object sender, UnhandledExceptionEventArgs e) => Logger.LogError(e.ExceptionObject?.ToString() ?? "Error message not found", e.ExceptionObject as Exception);

// First chance exception log all exceptions, even if caught.
AppDomain.CurrentDomain.FirstChanceException += (object? sender, FirstChanceExceptionEventArgs e) => Logger.LogError(e.Exception?.ToString() ?? "Error message not found", e.Exception);

// Unobserved tasks (_ = SomethingAsync()) can suppress exceptions, but can be observed and routed nonetheless.
TaskScheduler.UnobservedTaskException += (object? sender, UnobservedTaskExceptionEventArgs e) => Logger.LogError(e.Exception?.ToString() ?? "Error message not found", e.Exception);

// Logging invocation //
////////////////////////
// Logs the general flow of the application. Can be used for interactive investigation during development.
Logger.LogInformation(information);

// Logs when the current flow of execution is stopped due to a failure. These should indicate a failure in the current activity, not an application-wide failure.
Logger.LogError(message, exception);

// Logs that highlight an abnormal or unexpected event in the application flow, but do not otherwise cause the application execution to stop.
Logger.LogWarning(message);

// Logs an extremely detailed message. May contain sensitive application data. These messages should never be enabled in a production environment.
Logger.LogTrace(message);

// Logs an unrecoverable application or system crash, or a catastrophic failure that requires immediate attention.
Logger.LogCritical(message);

ProcessHelpers

// Collect both output and error
var (output, error) = await ProcessHelpers.RunExecutable(new SystemFile("/path/to/binary"), arguments: $"-id \"{id}\" -port {portNumber}");

// Throwing instead of returning error
var (output, _) = await ProcessHelpers.RunExecutable(new SystemFile("/path/to/binary"), arguments: $"-id \"{id}\" -port {portNumber}", throwOnError: true);

Financing

We accept donations here and here, and we do not have any active bug bounties.

Versioning

Version numbering follows the Semantic versioning approach. However, if the major version is 0, the code is considered alpha and breaking changes may occur as a minor update.

License

All OwlCore code is licensed under the MIT License. OwlCore is licensed under the MIT License. See the LICENSE file for more details.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on OwlCore.Diagnostics:

Package Downloads
OwlCore

Have you ever seen an owl do a barrel roll? Me neither. Essential supplemental tooling for .NET development.

OwlCore.Kubo

An essential toolkit for Kubo, IPFS and the distributed web.

OwlCore.Nomad.Kubo

Shared tooling for building Nomad-enabled applications on ipfs

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.0.0 1,487 7/23/2024

--- 0.0.0 ---
[New]
Initial release of OwlCore.Diagnostics.