aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Horizon/LogManager/Types/LogPacket.cs
blob: b4294d66af046baf87456f7e98a559ef66ae9766 (plain)
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
using Ryujinx.Horizon.Sdk.Diag;
using System.Text;

namespace Ryujinx.Horizon.LogManager.Types
{
    struct LogPacket
    {
        public string Message;
        public int Line;
        public string Filename;
        public string Function;
        public string Module;
        public string Thread;
        public long DropCount;
        public long Time;
        public string ProgramName;
        public LogSeverity Severity;

        public override string ToString()
        {
            StringBuilder builder = new();
            builder.AppendLine($"Guest Log:\n  Log level: {Severity}");

            if (Time > 0)
            {
                builder.AppendLine($"    Time: {Time}s");
            }

            if (DropCount > 0)
            {
                builder.AppendLine($"    DropCount: {DropCount}");
            }

            if (!string.IsNullOrEmpty(ProgramName))
            {
                builder.AppendLine($"    ProgramName: {ProgramName}");
            }

            if (!string.IsNullOrEmpty(Module))
            {
                builder.AppendLine($"    Module: {Module}");
            }

            if (!string.IsNullOrEmpty(Thread))
            {
                builder.AppendLine($"    Thread: {Thread}");
            }

            if (!string.IsNullOrEmpty(Filename))
            {
                builder.AppendLine($"    Filename: {Filename}");
            }

            if (Line > 0)
            {
                builder.AppendLine($"    Line: {Line}");
            }

            if (!string.IsNullOrEmpty(Function))
            {
                builder.AppendLine($"    Function: {Function}");
            }

            if (!string.IsNullOrEmpty(Message))
            {
                builder.AppendLine($"    Message: {Message}");
            }

            return builder.ToString();
        }
    }
}