diff Implab/Diagnostics/TraceLog.cs @ 36:313f708a50e9 diagnostics

improved log concept
author cin
date Tue, 15 Apr 2014 02:00:09 +0400
parents
children fe33f4e02ad5
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Implab/Diagnostics/TraceLog.cs	Tue Apr 15 02:00:09 2014 +0400
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Implab.Diagnostics {
+    /// <summary>
+    /// Класс для публикации событий выполнения программы, события публикуются через <see cref="LogChannel{TraceEvent}"/>
+    /// </summary>
+    public static class TraceLog {
+        [Conditional("TRACE")]
+        public static void Transfer(TraceContext from) {
+            TraceContext.Transfer(from);
+        }
+
+        [Conditional("TRACE")]
+        public static void StartLogicalOperation() {
+            TraceContext.Current.StartLogicalOperation();
+        }
+
+        [Conditional("TRACE")]
+        public static void StartLogicalOperation(string name) {
+            TraceContext.Current.StartLogicalOperation(name);
+        }
+
+        [Conditional("TRACE")]
+        public static void EndLogicalOperation() {
+            TraceContext.Current.EndLogicalOperation();
+        }
+
+        [Conditional("TRACE")]
+        public static void TraceInformation(string format, params object[] arguments) {
+            LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Information, format, arguments));
+        }
+
+        [Conditional("TRACE")]
+        public static void TraceWarning(string format, params object[] arguments) {
+            LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Warning, format, arguments));
+        }
+
+        [Conditional("TRACE")]
+        public static void TraceError(string format, params object[] arguments) {
+            LogChannel<TraceEvent>.Default.LogEvent(TraceEvent.Create(TraceEventType.Error, format, arguments));
+        }
+
+        [Conditional("TRACE")]
+        public static void TraceError(Exception err) {
+            TraceError("{0}", err);
+        }
+    }
+}