예제 #1
0
        public static IDisposable Activity(this IDiagnosticsSource self,
                                           string name,
                                           [CallerMemberName] string member = null,
                                           [CallerFilePath] string file     = null,
                                           [CallerLineNumber] int line      = 0)
        {
            var thisActivityId = Interlocked.Increment(ref _activityId);
            var start          = DateTime.UtcNow;

            self.TraceEvent(TraceEventType.Start,
                            id: thisActivityId,
                            message: String.Format(CultureInfo.CurrentCulture, "Starting {0}", name),
                            member: member,
                            file: file,
                            line: line);
            return(new DisposableAction(() =>
            {
                var diff = DateTime.UtcNow - start;
                var stopMessage = String.Format(CultureInfo.CurrentCulture, "Finished {0}. Duration {1:0.00}ms", name, diff.TotalMilliseconds);
                self.TraceEvent(TraceEventType.Stop,
                                id: thisActivityId,
                                message: stopMessage,
                                member: member,
                                file: file,
                                line: line);
            }));
        }
예제 #2
0
 public static void Warning(this IDiagnosticsSource self,
                            string message,
                            [CallerMemberName] string member = null,
                            [CallerFilePath] string file     = null,
                            [CallerLineNumber] int line      = 0)
 {
     self.TraceEvent(TraceEventType.Warning, id: 0, message: message, member: member, file: file, line: line);
 }
예제 #3
0
 public static void Error(this IDiagnosticsSource self,
                             string message,
                             [CallerMemberName] string member = null,
                             [CallerFilePath] string file = null,
                             [CallerLineNumber] int line = 0)
 {
     self.TraceEvent(LogLevel.Error, eventId: 0, message: message, member: member, file: file, line: line);
 }
예제 #4
0
 public static void Error(this IDiagnosticsSource self,
                          string message,
                          int id,
                          [CallerMemberName] string member = null,
                          [CallerFilePath] string file     = null,
                          [CallerLineNumber] int line      = 0)
 {
     self.TraceEvent(TraceEventType.Error, id, message, member, file, line);
 }
예제 #5
0
 public static void Warning(this IDiagnosticsSource self,
                             string message,
                             EventId eventId,
                             [CallerMemberName] string member = null,
                             [CallerFilePath] string file = null,
                             [CallerLineNumber] int line = 0)
 {
     self.TraceEvent(LogLevel.Warning, eventId, message, member, file, line);
 }
        public static IDisposable Activity(this IDiagnosticsSource self,
                                           string name,
                                           [CallerMemberName] string member = null,
                                           [CallerFilePath] string file     = null,
                                           [CallerLineNumber] int line      = 0)
        {
            self.TraceEvent(TraceEventType.Start,
                            id: 0,
                            message: String.Format(CultureInfo.CurrentCulture, "Starting {0}", name),
                            member: member,
                            file: file,
                            line: line);
            var stopMessage = String.Format(CultureInfo.CurrentCulture, "Starting {0}", name);

            return(new DisposableAction(() =>
                                        self.TraceEvent(TraceEventType.Stop,
                                                        id: 0,
                                                        message: stopMessage,
                                                        member: member,
                                                        file: file,
                                                        line: line)));
        }