Esempio n. 1
0
        public void VariantWriteLinuxUnstructured(
            ref GenericEventDescriptor genericEventDescriptor,
            int argCount,
            Variant v0  = default(Variant),
            Variant v1  = default(Variant),
            Variant v2  = default(Variant),
            Variant v3  = default(Variant),
            Variant v4  = default(Variant),
            Variant v5  = default(Variant),
            Variant v6  = default(Variant),
            Variant v7  = default(Variant),
            Variant v8  = default(Variant),
            Variant v9  = default(Variant),
            Variant v10 = default(Variant),
            Variant v11 = default(Variant),
            Variant v12 = default(Variant),
            Variant v13 = default(Variant))
        {
            int    eventId = genericEventDescriptor.EventId;
            string text    = string.Format(
                this.eventDescriptors[eventId].Message, new object[]
                { v0.ToObject(), v1.ToObject(), v2.ToObject(), v3.ToObject(), v4.ToObject(), v5.ToObject(), v6.ToObject(), v7.ToObject(), v8.ToObject(), v9.ToObject(), v10.ToObject(), v11.ToObject(), v12.ToObject(), v13.ToObject() }
                );

            string id             = this.eventDescriptors[eventId].hasId && !string.IsNullOrWhiteSpace(v0.ConvertToString()) ? v0.ConvertToString() : eventId.ToString();
            int    typeFieldIndex = this.eventDescriptors[eventId].typeFieldIndex;
            string type           = this.eventDescriptors[eventId].EventName;

            if (this.eventDescriptors[eventId].typeFieldIndex != -1)
            {
                string typeField = GetTypeFromIndex(typeFieldIndex, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13);
                if (!string.IsNullOrWhiteSpace(typeField))
                {
                    type = typeField;
                }
            }

            TraceViaNative.WriteUnstructured(FabricEvents.Events.GetEventTaskName((EventTask)genericEventDescriptor.Task), type, id, genericEventDescriptor.Level, text);
        }
Esempio n. 2
0
        public unsafe void VariantWrite(ref GenericEventDescriptor genericEventDescriptor, int argCount,
                                        Variant v1  = default(Variant), Variant v2  = default(Variant), Variant v3  = default(Variant),
                                        Variant v4  = default(Variant), Variant v5  = default(Variant), Variant v6  = default(Variant),
                                        Variant v7  = default(Variant), Variant v8  = default(Variant), Variant v9  = default(Variant),
                                        Variant v10 = default(Variant), Variant v11 = default(Variant), Variant v12 = default(Variant),
                                        Variant v13 = default(Variant), Variant v14 = default(Variant))
        {
            if (argCount == 0)
            {
#if !DotNetCoreClrLinux
                this.WriteEvent(genericEventDescriptor.EventId);
#else
                TraceViaNative.WriteStructured(ref genericEventDescriptor, 0, null);
#endif
                return;
            }

            Tracing.EventData *eventSourceData = stackalloc Tracing.EventData[argCount];
            byte *dataBuffer = stackalloc byte[EventDataArrayBuilder.BasicTypeAllocationBufferSize * argCount];
            var   edb        = new EventDataArrayBuilder(eventSourceData, dataBuffer);

            if (!edb.AddEventDataWithTruncation(argCount, ref v1, ref v2, ref v3, ref v4, ref v5, ref v6, ref v7, ref v8, ref v9, ref v10, ref v11, ref v12, ref v13, ref v14))
            {
                Debug.Fail(string.Format("EventData for eventid {0} is invalid. Check the total size of the event.",
                                         genericEventDescriptor.EventId));
                return;
            }

            fixed(char *s1 = v1.ConvertToString(),
                  s2       = v2.ConvertToString(),
                  s3       = v3.ConvertToString(),
                  s4       = v4.ConvertToString(),
                  s5       = v5.ConvertToString(),
                  s6       = v6.ConvertToString(),
                  s7       = v7.ConvertToString(),
                  s8       = v8.ConvertToString(),
                  s9       = v9.ConvertToString(),
                  s10      = v10.ConvertToString(),
                  s11      = v11.ConvertToString(),
                  s12      = v12.ConvertToString(),
                  s13      = v13.ConvertToString(),
                  s14      = v14.ConvertToString())
            {
                var tracingEventDataPtr = edb.ToEventDataArray(s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14);

                // Convert to EventSource.EventData from Tracing.EventData.
#if !DotNetCoreClrLinux
                EventData *eventDataPtr = stackalloc EventData[argCount];
                for (uint i = 0; i < argCount; ++i)
                {
                    eventDataPtr[i].DataPointer = (IntPtr)tracingEventDataPtr[i].DataPointer;
                    eventDataPtr[i].Size        = (int)tracingEventDataPtr[i].Size;
                }

                this.WriteEventCore(genericEventDescriptor.EventId, argCount, eventDataPtr);
#else
                EventDataDescriptor *eventDataPtr = stackalloc EventDataDescriptor[argCount];
                for (uint i = 0; i < argCount; ++i)
                {
                    eventDataPtr[i].DataPointer = (UInt64)tracingEventDataPtr[i].DataPointer;
                    eventDataPtr[i].Size        = tracingEventDataPtr[i].Size;
                }

                TraceViaNative.WriteStructured(ref genericEventDescriptor, (uint)argCount, eventDataPtr);
#endif
            }
        }