LogEventArgsJson.cs 941 B

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