summaryrefslogtreecommitdiff
path: root/src/mscorlib/src/System/Diagnostics/Eventing/TraceLogging/EventSourceOptions.cs
blob: 603679b5fff318960cb44fdd0aba7f24d35b3f73 (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;

#if ES_BUILD_STANDALONE
namespace Microsoft.Diagnostics.Tracing
#else
namespace System.Diagnostics.Tracing
#endif
{
    /// <summary>
    /// Used when calling EventSource.Write.
    /// Optional overrides for event settings such as Level, Keywords, or Opcode.
    /// If overrides are not provided for a setting, default values will be used.
    /// </summary>
    public struct EventSourceOptions
    {
        internal EventKeywords keywords;
        internal EventTags tags;
        internal EventActivityOptions activityOptions;
        internal byte level;
        internal byte opcode;
        internal byte valuesSet;

        internal const byte keywordsSet = 0x1;
        internal const byte tagsSet = 0x2;
        internal const byte levelSet = 0x4;
        internal const byte opcodeSet = 0x8;
        internal const byte activityOptionsSet = 0x10;

        /// <summary>
        /// Gets or sets the level to use for the specified event. If this property
        /// is unset, the event's level will be 5 (Verbose).
        /// </summary>
        public EventLevel Level
        {
            get
            {
                return (EventLevel)this.level;
            }

            set
            {
                this.level = checked((byte)value);
                this.valuesSet |= levelSet;
            }
        }

        /// <summary>
        /// Gets or sets the opcode to use for the specified event. If this property
        /// is unset, the event's opcode will 0 (Info).
        /// </summary>
        public EventOpcode Opcode
        {
            get
            {
                return (EventOpcode)this.opcode;
            }

            set
            {
                this.opcode = checked((byte)value);
                this.valuesSet |= opcodeSet;
            }
        }

        internal bool IsOpcodeSet
        {
            get
            {
                return (this.valuesSet & opcodeSet) != 0;
            }
        }

        /// <summary>
        /// Gets or sets the keywords to use for the specified event. If this
        /// property is unset, the event's keywords will be 0.
        /// </summary>
        public EventKeywords Keywords
        {
            get
            {
                return this.keywords;
            }

            set
            {
                this.keywords = value;
                this.valuesSet |= keywordsSet;
            }
        }

        /// <summary>
        /// Gets or sets the tags to use for the specified event. If this property is
        /// unset, the event's tags will be 0.
        /// </summary>
        public EventTags Tags
        {
            get
            {
                return this.tags;
            }

            set
            {
                this.tags = value;
                this.valuesSet |= tagsSet;
            }
        }

        /// <summary>
        /// Gets or sets the activity options for this specified events. If this property is
        /// unset, the event's activity options will be 0.
        /// </summary>
        public EventActivityOptions ActivityOptions
        {
            get
            {
                return this.activityOptions;
            }
            set
            {
                this.activityOptions = value;
                this.valuesSet |= activityOptionsSet;
            }
        }
    }
}