CapedLog.core
2.2.4
Renaming package
dotnet add package CapedLog.core --version 2.2.4
NuGet\Install-Package CapedLog.core -Version 2.2.4
<PackageReference Include="CapedLog.core" Version="2.2.4" />
paket add CapedLog.core --version 2.2.4
#r "nuget: CapedLog.core, 2.2.4"
// Install CapedLog.core as a Cake Addin #addin nuget:?package=CapedLog.core&version=2.2.4 // Install CapedLog.core as a Cake Tool #tool nuget:?package=CapedLog.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 CapedLog.CapedLog();
var conf = new CapedLog.CapedLogConf(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(() => CapedLog.CapedLogMessage.Create("msg1"));
metric.TryEnqueue(() => CapedLog.CapedLogMessage.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 : CapedLog.IScrapeProcess
{
public Task<int> Send(IReadOnlyList<CapedLog.CapedLogMetric> metrics, CancellationToken cancellation)
{
var result = 0;
var temp = new List<CapedLog.CapedLogMessage>();
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 CapedLog.CapedLog();
var conf = new CapedLog.CapedLogConfBuilder()
.AddConstLabel("foo", "1")
.SetDefaultCapacity(10)
.Build();
var container = log.GetOrCreate(conf);
var scrape = CapedLog.CapedLogScrape.CreateScrape(log, new MyScrapeProcess());
var metric = container.GetMetric(Array.Empty<string>());
var cancellation = new CancellationTokenSource();
//Sending messages to the log
metric.TryEnqueue(() => CapedLog.CapedLogMessage.Create("msg1"));
metric.TryEnqueue(() => CapedLog.CapedLogMessage.Create("msgN"));
// Periodic collection of messages from the log
var myScrapeProcessResult = scrape(cancellation.Token).Result;
Assert.AreEqual(2, myScrapeProcessResult);
Product | Versions 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. |
This package has no dependencies.
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 | |
---|---|---|---|
2.2.4 | 716 | 10/8/2019 |