LogEventArgsJson.cs 900 B

123456789101112131415161718192021222324252627282930
  1. using System;
  2. using System.Text.Json.Serialization;
  3. namespace Ryujinx.Common.Logging
  4. {
  5. internal class LogEventArgsJson
  6. {
  7. public LogLevel Level { get; }
  8. public TimeSpan Time { get; }
  9. public string ThreadName { get; }
  10. public string Message { get; }
  11. public string Data { get; }
  12. [JsonConstructor]
  13. public LogEventArgsJson(LogLevel level, TimeSpan time, string threadName, string message, string data = null)
  14. {
  15. Level = level;
  16. Time = time;
  17. ThreadName = threadName;
  18. Message = message;
  19. Data = data;
  20. }
  21. public static LogEventArgsJson FromLogEventArgs(LogEventArgs args)
  22. {
  23. return new LogEventArgsJson(args.Level, args.Time, args.ThreadName, args.Message, DynamicObjectFormatter.Format(args.Data));
  24. }
  25. }
  26. }