-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccessLogItem.cs
80 lines (71 loc) · 2.91 KB
/
AccessLogItem.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// <auto-generated />
//
// To parse this JSON data, add NuGet 'Newtonsoft.Json' then do:
//
// using CaddyLogParser;
//
// var accessLogItem = AccessLogItem.FromJson(jsonString);
namespace CaddyLogParser
{
using System;
using System.Collections.Generic;
using System.Globalization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using J = Newtonsoft.Json.JsonPropertyAttribute;
using R = Newtonsoft.Json.Required;
using N = Newtonsoft.Json.NullValueHandling;
public partial class AccessLogItem
{
[J("level")] public string Level { get; set; }
[J("ts")] public double Timestamp { get; set; }
[J("logger")] public string Logger { get; set; }
[J("msg")] public string Msg { get; set; }
[J("request")] public Request Request { get; set; }
[J("common_log")] public string CommonLogField { get; set; }
[J("duration")] public double Duration { get; set; }
[J("size")] public long Size { get; set; }
[J("status")] public long Status { get; set; }
[J("resp_headers")] public Dictionary<string, List<string>> ResponseHeaders { get; set; }
public override string ToString() => CommonLogField;
}
public partial class Request
{
[J("method")] public string Method { get; set; }
[J("uri")] public string Uri { get; set; }
[J("proto")] public string Proto { get; set; }
[J("remote_addr")] public string RemoteAddress { get; set; }
[J("host")] public string Host { get; set; }
[J("headers")] public Dictionary<string, List<string>> Headers { get; set; }
[J("tls", NullValueHandling = N.Ignore)] public TLSStatus TlsStatus { get; set; }
}
public partial class TLSStatus
{
[J("resumed")] public bool Resumed { get; set; }
[J("version")] public long Version { get; set; }
[J("ciphersuite")] public long CipherSuite { get; set; }
[J("proto")] public string Proto { get; set; }
[J("proto_mutual")] public bool ProtoMutual { get; set; }
[J("server_name")] public string ServerName { get; set; }
}
public partial class AccessLogItem
{
public static AccessLogItem FromJson(string json) => JsonConvert.DeserializeObject<AccessLogItem>(json, CaddyLogParser.Converter.Settings);
}
public static class Serialize
{
public static string ToJson(this AccessLogItem self) => JsonConvert.SerializeObject(self, CaddyLogParser.Converter.Settings);
}
internal static class Converter
{
public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
{
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
DateParseHandling = DateParseHandling.None,
Converters =
{
new IsoDateTimeConverter { DateTimeStyles = DateTimeStyles.AssumeUniversal }
},
};
}
}