-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogSerializeOptions.cs
47 lines (42 loc) · 1.62 KB
/
LogSerializeOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace Microsoft.Extensions.Logging.Serialization;
/// <summary>
/// Options for serializing log entries.
/// </summary>
public class LogSerializeOptions<TFormat>
{
/// <summary>
/// Gets or sets the maximum number of log entry bytes to store in memory.
/// </summary>
/// <remarks>
/// Defaults to <c>4096</c>. The actual size may be less based on <see cref="BufferInterval"/>.
/// </remarks>
public int BufferSize { get; set; } = 4096;
/// <summary>
/// Gets or sets the maximum log time interval to store in memory.
/// </summary>
/// <remarks>
/// Defaults to one second. The actual interval may be less based on <see cref="BufferSize"/>.
/// </remarks>
public TimeSpan BufferInterval { get; set; } = TimeSpan.FromSeconds(1);
/// <summary>
/// Gets or sets the bytes used to delimit log entries.
/// </summary>
/// <remarks>
/// Defaults to <see cref="Environment.NewLine"/>.
/// </remarks>
public byte[] Delimiter { get; set; } = Encoding.ASCII.GetBytes(Environment.NewLine);
/// <summary>
/// Gets or sets the serializer for log entries.
/// </summary>
public ILogEntrySerializer<TFormat>? Serializer { get; set; }
/// <summary>
/// Configures JSON serialization of log entries.
/// </summary>
/// <param name="jsonOptions">Options for the JSON serializer.</param>
/// <returns>The same options, for chaining.</returns>
public LogSerializeOptions<TFormat> AsJson(JsonSerializerOptions? jsonOptions = null)
{
this.Serializer = new JsonLogSerializer<TFormat>(jsonOptions ?? new());
return this;
}
}