DevInstance.LogScope 1.4.3

dotnet add package DevInstance.LogScope --version 1.4.3
                    
NuGet\Install-Package DevInstance.LogScope -Version 1.4.3
                    
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="DevInstance.LogScope" Version="1.4.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DevInstance.LogScope" Version="1.4.3" />
                    
Directory.Packages.props
<PackageReference Include="DevInstance.LogScope" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DevInstance.LogScope --version 1.4.3
                    
#r "nuget: DevInstance.LogScope, 1.4.3"
                    
#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.
#addin nuget:?package=DevInstance.LogScope&version=1.4.3
                    
Install DevInstance.LogScope as a Cake Addin
#tool nuget:?package=DevInstance.LogScope&version=1.4.3
                    
Install DevInstance.LogScope as a Cake Tool

LogScope.NET Standard: Logging, tracing and profiling

LogScope.NET is a lightweight logging framework designed for tracing, profiling, and logging critical parts of your code. It can seamlessly integrate with popular logging libraries like Log4Net and NLog.

The framework revolves around the concept of a "scope," which can represent a method or a specific part of it. The implementation is based on the IDisposable interface, where calling Dispose method marks the end of the scope.

Additionally, it offers more streamlined coding and shorter lines of code compared to the conventional logging APIs.

Here's an example that illustrates this approach:

class TestClass
{
    IScopeLog classScope;

    public TestClass(IScopeManager manager)
    {
        classScope = manager.CreateLogger(this);
    }

    public void MethodA()
    {
        using (var methodScope = classScope.DebugScope())
        {
            methodScope.D("Wait for 200 msec");
            Thread.Sleep(200);
            methodScope.D("Done.");
            using (var aScope = methodScope.DebugScope("a-scope"))
            {
                aScope.D("Inside of a scope");
            }
            MethodB();
        }
    }

    private void MethodB()
    {
        using (var methodScope = classScope.DebugScope())
        {
            methodScope.D("Inside of method B scope");
            Thread.Sleep(200);
        }
    }
}

Result:

21-01-29 23:07:24--> TestClass:MethodA
21-01-29 23:07:24    TestClass:MethodA:Wait for 200 msec
21-01-29 23:07:25    TestClass:MethodA:Done.
21-01-29 23:07:25--> TestClass:MethodA:a-scope
21-01-29 23:07:25    TestClass:MethodA:a-scope:Inside of a scope
21-01-29 23:07:25<-- TestClass:MethodA:a-scope, time:2.1252 msec
21-01-29 23:07:25--> TestClass:MethodB
21-01-29 23:07:25    TestClass:MethodB:Inside of method B scope
21-01-29 23:07:25<-- TestClass:MethodB, time:212.748 msec
21-01-29 23:07:25<-- TestClass:MethodA, time:480.5525 msec

Setup

LogScope package is available on NuGet (https://www.nuget.org/packages/DevInstance.LogScope/). The default implementation is based on simple Console.Log calls. There is an extension available for the standard Microsoft logger: https://www.nuget.org/packages/DevInstance.LogScope.Extensions.MicrosoftLogger/

So, add the package reference to your project:

Power shell:

  • .Net Standard 2.0: dotnet add package DevInstance.LogScope
  • .Net 6+: dotnet add package DevInstance.LogScope.NET
  • Mocrosoft Loggering extension (.Net 6+): DevInstance.LogScope.Extensions.MicrosoftLogger

Package manager:

  • .Net Standard 2.0: Install-Package DevInstance.LogScope
  • .Net 6+: Install-PackageDevInstance.LogScope.NET
  • Mocrosoft Loggering extension (.Net 6+): Install-Package DevInstance.LogScope.Extensions.MicrosoftLogger

Initialization

Initialization differs based on the type of the application and logging provider. If application uses dependency injection just call the AddConsoleScopeLogging extension method:

public void ConfigureServices(IServiceCollection services)
{
    //...
    services.AddConsoleScopeLogging(LogLevel.DEBUG);
    //...
}

For console application if can be instantiated by using DefaultScopeLogFactory directly:

var manager = DefaultScopeLogFactory.CreateConsoleLogger(LogLevel.DEBUG);

For MicrosoftLogger extension, call:

public void ConfigureServices(IServiceCollection services)
{
    //...
    services.AddMicrosoftScopeLogging(new DefaultFormattersOptions { ShowTimestamp = true, ShowThreadNumber = true });
    //...
}

See more information about API: http://logscope.devinstance.net/

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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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 (5)

Showing the top 5 NuGet packages that depend on DevInstance.LogScope:

Package Downloads
DevInstance.LogScope.Extensions.MicrosoftLogger

Microsoft logging extension integration with the LogScope. Read more: http://devinstance.net/blog/dotnet-standard-logging-and-profiling

DevInstance.Timelines.Blazor

Timelines is a chart library to help visualizing timelines and report for nocrast.com. This is still a working in progress and early version.

DevInstance.LogScope.NET

LogScope implements simple logging framework for tracing, profiling and logging methods and critical parts of the code. LogScope is not yet another logger. It is an extension of existing logging libraries that provides alternative way of logging and measuring a performance of critical parts of code. It also helps building a cleaner picture of executing asynchronous calls. The whole idea is based on a “scope”. Scope can be method or a specific part of it. The implementation is based on IDisposable where calling Dispose ends the scope. Quick introduction: https://devinstance.net/blog/introducing-logscope Documentation: http://logscope.devinstance.net

DevInstance.BlazorToolkit

BlazorToolkit is a comprehensive set of tools designed to enhance the development of Blazor applications. It provides a suite of utilities and services that streamline common tasks, allowing developers to focus on building rich, interactive web applications.

DevInstance.Timelines

Timelines is a chart library to help visualizing timelines and report for nocrast.com. This is still a working in progress and early version.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.4.3 194 12/19/2024
1.4.2 1,219 8/18/2022
1.4.0 717 2/14/2022
1.3.0 521 11/30/2021
1.2.0 552 5/30/2021
1.1.0 477 5/4/2021
1.0.0 376 2/24/2021
1.0.0-preview02192020 270 2/20/2021
0.9.1 397 1/31/2021

Release notes for 1.4.3:
- Minor adjustments and updates;
Release notes for 1.4.2:
- Some performance improvements of the scope logging;
Release notes for 1.4.1:
- Added ability to track scope instance using 'Scope.Id";