aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Common/Logging/LogEventArgsJson.cs
blob: 7c745d63e1f7d5d7aa4963d59dd87324cbb8a943 (plain) (blame)
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
using Ryujinx.Common.Logging.Formatters;
using System;
using System.Text.Json.Serialization;

namespace Ryujinx.Common.Logging
{
    internal class LogEventArgsJson
    {
        public LogLevel Level { get; }
        public TimeSpan Time { get; }
        public string ThreadName { get; }

        public string Message { get; }
        public string Data { get; }

        [JsonConstructor]
        public LogEventArgsJson(LogLevel level, TimeSpan time, string threadName, string message, string data = null)
        {
            Level = level;
            Time = time;
            ThreadName = threadName;
            Message = message;
            Data = data;
        }

        public static LogEventArgsJson FromLogEventArgs(LogEventArgs args)
        {
            return new LogEventArgsJson(args.Level, args.Time, args.ThreadName, args.Message, DynamicObjectFormatter.Format(args.Data));
        }
    }
}