-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tidy logging, lamire upfront threshold
- Loading branch information
1 parent
0c7ca6c
commit 9a1d990
Showing
7 changed files
with
106 additions
and
218 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
namespace CsCheck; | ||
|
||
using System.Text.Json; | ||
using System.Threading.Channels; | ||
|
||
public static class GenLogger | ||
{ | ||
public record LogContext<T>(T Value, bool Success); | ||
|
||
public enum LogProcessor | ||
{ | ||
Tyche | ||
} | ||
|
||
public static Func<(Func<Task> loggingTask, Channel<LogContext<T>>)> CreateLogger<T>(StreamWriter w, LogProcessor p, string propertyUnderTest) | ||
{ | ||
return () => | ||
{ | ||
w.AutoFlush = true; | ||
var channel = Channel.CreateUnbounded<LogContext<T>>( | ||
new UnboundedChannelOptions | ||
{ | ||
SingleReader = true, | ||
SingleWriter = false | ||
} | ||
); | ||
switch (p) | ||
{ | ||
case LogProcessor.Tyche: | ||
var t = async () => | ||
{ | ||
while (await channel.Reader.WaitToReadAsync().ConfigureAwait(false)) | ||
{ | ||
var d = new Dictionary<string, string>(StringComparer.Ordinal); | ||
var item = await channel.Reader.ReadAsync().ConfigureAwait(false); | ||
var value = item.Value; | ||
var timestamp = ((DateTimeOffset)DateTime.UtcNow).ToUnixTimeMilliseconds() / 1000.0; | ||
var tycheData = new TycheData( | ||
"test_case", timestamp, propertyUnderTest, | ||
item.Success ? "passed" : "failed", JsonSerializer.Serialize(value), | ||
"reason", d, "testing", d, null, d, d | ||
); | ||
var serializedData = JsonSerializer.Serialize(tycheData); | ||
await w.WriteLineAsync(serializedData).ConfigureAwait(false); | ||
} | ||
}; | ||
return (t, channel); | ||
default: | ||
throw new ArgumentOutOfRangeException(nameof(p), p, null); | ||
} | ||
}; | ||
} | ||
} | ||
|
||
public record TycheData(string type, double run_start, string property, string status, string representation, | ||
string? status_reason, Dictionary<string, string> arguments, string? how_generated, Dictionary<string, string> features, | ||
Dictionary<string, string>? coverage, Dictionary<string, string> timing, Dictionary<string, string> metadata); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.