示例#1
0
        internal static string FormatEvent(FormatVersion formatVersion, IFormatProvider provider, EventRecord eventRecord, string eventSourceName, string eventLevel, string eventTaskName, string opcodeName, string keywordsName, string type, string text)
        {
            switch (formatVersion)
            {
            case FormatVersion.TaskBasedFormatting:
            {
                return(string.Format(
                           provider,
                           "{0},{1},{2},{3},{4}.{5},{6}",
                           EventFormatter.FormatTimeStamp(provider, eventRecord.EventHeader.TimeStamp),
                           eventLevel,
                           eventRecord.EventHeader.ThreadId,
                           eventRecord.EventHeader.ProcessId,
                           eventTaskName,
                           type,
                           text));
            }

            case FormatVersion.EventSourceBasedFormatting:
            {
                return(string.Format(
                           provider,
                           "{0},{1},{2},{3},{4}.{5},{6}",
                           EventFormatter.FormatTimeStamp(provider, eventRecord.EventHeader.TimeStamp),
                           eventLevel,
                           eventRecord.EventHeader.ThreadId,
                           eventRecord.EventHeader.ProcessId,
                           eventSourceName,
                           type,
                           text));
            }

            default:
            {
                return(string.Format(
                           provider,
                           "{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11}",
                           EventFormatter.FormatTimeStamp(provider, eventRecord.EventHeader.TimeStamp),
                           eventRecord.EventHeader.ThreadId,
                           eventRecord.EventHeader.ProcessId,
                           eventRecord.EventHeader.EventDescriptor.Id,
                           eventRecord.EventHeader.ActivityId,
                           GetRelatedActivityId(eventRecord),
                           eventLevel,
                           String.IsNullOrEmpty(eventTaskName) ?
                           eventRecord.EventHeader.EventDescriptor.Task.ToString(provider) :
                           eventTaskName,
                           String.IsNullOrEmpty(opcodeName) ?
                           eventRecord.EventHeader.EventDescriptor.Opcode.ToString(provider) :
                           opcodeName,
                           String.IsNullOrEmpty(keywordsName) ?
                           eventRecord.EventHeader.EventDescriptor.Keyword.ToString("X", provider) :
                           keywordsName,
                           type,
                           text));
            }
            }
        }
示例#2
0
        private static string FormatTimeStamp(IFormatProvider provider, long fileTime)
        {
            DateTime timestamp = DateTime.FromFileTimeUtc(fileTime);

            return(EventFormatter.FormatTimeStamp(provider, timestamp));
        }