CappedLog.core 2.2.4

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

// Install CappedLog.core as a Cake Tool
#tool nuget:?package=CappedLog.core&version=2.2.4                

Container of log

Implementation of a container for storing logs.

Each container has a maximum number of records upon reaching which writing to the container becomes impossible until the external reader processes all the records from the container. This allows you to avoid memory overflow while increasing the flow of messages in the log between the operations of processing the log data (saving to disk or sending over the network).

Additionally, each container can have meta-information (a set of static and dynamic labels)

var log = new CappedLog.CappedLog();
var conf = new CappedLog.CappedLogConf(new[] { new KeyValuePair<string, string>("const_label_name", "const_label_value") }, new[] { "dynamic_label_name1", "dynamic_label_name2" }, 10);
var container = log.GetOrCreate(conf);
var metric = container.GetMetric(new[] { "dynamic_label_value1", "dynamic_label_value2" });
metric.TryEnqueue(() => CappedLog.CappedLogMessage.Create("msg1"));
metric.TryEnqueue(() => CappedLog.CappedLogMessage.Create("msgN"));

Scrape log messages process

To collect accumulated messages in the log, you must implement a background message processing process that will be periodically started

class MyScrapeProcess : CappedLog.IScrapeProcess
{
    public Task<int> Send(IReadOnlyList<CappedLog.CappedLogMetric> metrics, CancellationToken cancellation)
    {
        var result = 0;
        var temp = new List<CappedLog.CappedLogMessage>();
        foreach (var metric in metrics)
        {
            if (metric.DequeueAll(temp) == 0)
                continue;

            //Do something

            result += temp.Count;
            temp.Clear();
        }

        return Task.FromResult(result);
    }
}

...

var log = new CappedLog.CappedLog();
var conf = new CappedLog.CappedLogConfBuilder()
    .AddConstLabel("foo", "1")
    .SetDefaultCapacity(10)
    .Build();
var container = log.GetOrCreate(conf);
var scrape = CappedLog.CappedLogScrape.CreateScrape(log, new MyScrapeProcess());
var metric = container.GetMetric(Array.Empty<string>());
var cancellation = new CancellationTokenSource();

//Sending messages to the log
metric.TryEnqueue(() => CappedLog.CappedLogMessage.Create("msg1"));
metric.TryEnqueue(() => CappedLog.CappedLogMessage.Create("msgN"));

// Periodic collection of messages from the log
var myScrapeProcessResult = scrape(cancellation.Token).Result;

Assert.AreEqual(2, myScrapeProcessResult);
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.

This package has no dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on CappedLog.core:

Package Downloads
CappedLog.provider

Extension for fixed size tagged log located in memory with Microsoft Logging API

CappedLog.loki

Extension for fixed size tagged log located in memory with Grafana Loki API

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.2.4 1,067 10/9/2019