From fc4b841fb6416d01c8406a7444ebd9b2cfe1a9df Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Sun, 5 May 2024 21:05:24 +0200 Subject: [PATCH] Added the README.md files --- CSV Metrics Logger Generator/README.md | 39 +++++++++++++++++++++++++- CSV Metrics Logger/README.md | 39 +++++++++++++++++++++++++- README.md | 39 +++++++++++++++++++++++++- 3 files changed, 114 insertions(+), 3 deletions(-) diff --git a/CSV Metrics Logger Generator/README.md b/CSV Metrics Logger Generator/README.md index 30404ce..643f477 100644 --- a/CSV Metrics Logger Generator/README.md +++ b/CSV Metrics Logger Generator/README.md @@ -1 +1,38 @@ -TODO \ No newline at end of file +# CSV Metrics Logger + +This is a simple CSV metrics logger that logs metrics to a CSV file. It is designed to be used in a multithreaded environment. Here is an example of how to use it: + +```csharp +using CSV_Metrics_Logger; + +[CSVRecord] +public readonly partial record struct TestData(string Name, sbyte Age); + +List testData = +[ + new TestData("Name 1", 14), + new TestData("Name 2", 25), + new TestData("Name 3", 36), + new TestData("Name 4", 47), + new TestData("Name 5", 58), +]; + +var filename = Path.GetTempFileName(); +await using var storage = CSVStorage.Create(fileName); + +foreach (var data in testData) + storage.Write(data); +``` + +You might use `storage.Write` from multiple threads. The logger will handle the synchronization for you. + +CSV Metrics Logger uses a source generator. You have to use the following NuGet packages: + +```xml + + +``` + +Your data must be modeled as a structure; classes are not supported. It does not matter if you are using a (readonly) record struct or a regular struct. The only requirement is that the struct must be a partial struct. The source generator will generate the missing part of the struct for you. Each public property will be used as a column in the CSV file. The property type might be any type, as long as it supports the `ToString(CultureInfo)` method. + +For each data structure, you create a CSVStorage instance. The CSVStorage instance is a disposable object. You must dispose of it when you are done with it. When the CSV file already exists, the CSVStorage object will append data to the existing file; the header will not be written again. \ No newline at end of file diff --git a/CSV Metrics Logger/README.md b/CSV Metrics Logger/README.md index 30404ce..643f477 100644 --- a/CSV Metrics Logger/README.md +++ b/CSV Metrics Logger/README.md @@ -1 +1,38 @@ -TODO \ No newline at end of file +# CSV Metrics Logger + +This is a simple CSV metrics logger that logs metrics to a CSV file. It is designed to be used in a multithreaded environment. Here is an example of how to use it: + +```csharp +using CSV_Metrics_Logger; + +[CSVRecord] +public readonly partial record struct TestData(string Name, sbyte Age); + +List testData = +[ + new TestData("Name 1", 14), + new TestData("Name 2", 25), + new TestData("Name 3", 36), + new TestData("Name 4", 47), + new TestData("Name 5", 58), +]; + +var filename = Path.GetTempFileName(); +await using var storage = CSVStorage.Create(fileName); + +foreach (var data in testData) + storage.Write(data); +``` + +You might use `storage.Write` from multiple threads. The logger will handle the synchronization for you. + +CSV Metrics Logger uses a source generator. You have to use the following NuGet packages: + +```xml + + +``` + +Your data must be modeled as a structure; classes are not supported. It does not matter if you are using a (readonly) record struct or a regular struct. The only requirement is that the struct must be a partial struct. The source generator will generate the missing part of the struct for you. Each public property will be used as a column in the CSV file. The property type might be any type, as long as it supports the `ToString(CultureInfo)` method. + +For each data structure, you create a CSVStorage instance. The CSVStorage instance is a disposable object. You must dispose of it when you are done with it. When the CSV file already exists, the CSVStorage object will append data to the existing file; the header will not be written again. \ No newline at end of file diff --git a/README.md b/README.md index 30404ce..643f477 100644 --- a/README.md +++ b/README.md @@ -1 +1,38 @@ -TODO \ No newline at end of file +# CSV Metrics Logger + +This is a simple CSV metrics logger that logs metrics to a CSV file. It is designed to be used in a multithreaded environment. Here is an example of how to use it: + +```csharp +using CSV_Metrics_Logger; + +[CSVRecord] +public readonly partial record struct TestData(string Name, sbyte Age); + +List testData = +[ + new TestData("Name 1", 14), + new TestData("Name 2", 25), + new TestData("Name 3", 36), + new TestData("Name 4", 47), + new TestData("Name 5", 58), +]; + +var filename = Path.GetTempFileName(); +await using var storage = CSVStorage.Create(fileName); + +foreach (var data in testData) + storage.Write(data); +``` + +You might use `storage.Write` from multiple threads. The logger will handle the synchronization for you. + +CSV Metrics Logger uses a source generator. You have to use the following NuGet packages: + +```xml + + +``` + +Your data must be modeled as a structure; classes are not supported. It does not matter if you are using a (readonly) record struct or a regular struct. The only requirement is that the struct must be a partial struct. The source generator will generate the missing part of the struct for you. Each public property will be used as a column in the CSV file. The property type might be any type, as long as it supports the `ToString(CultureInfo)` method. + +For each data structure, you create a CSVStorage instance. The CSVStorage instance is a disposable object. You must dispose of it when you are done with it. When the CSV file already exists, the CSVStorage object will append data to the existing file; the header will not be written again. \ No newline at end of file