##// END OF EJS Templates
removed absolete Diagnostics classes
cin -
r252:6f4630d0bcd9 v3
parent child
Show More
@@ -1,29 +1,37
1 1 using System;
2 2 using System.Diagnostics;
3 3 using System.Threading;
4 using Implab.Diagnostics;
4 5 using Xunit;
5 6
6 7 namespace Implab.Test
7 8 {
9 using static Trace<UnitTest1>;
8 10 public class UnitTest1
9 11 {
10 12 [Fact]
11 13 public void Test1()
12 14 {
13 15 var listener = new TextWriterTraceListener(Console.Out);
14 var source = new TraceSource("Custom",SourceLevels.ActivityTracing);
16 var source = TraceSource;
17 source.Switch.Level = SourceLevels.All;
15 18
16 19 source.Listeners.Add(listener);
20 Trace.Listeners.Add(listener);
17 21
18 Trace.Listeners.Add(listener);
19 22 Trace.WriteLine("Hello!");
20 Trace.CorrelationManager.StartLogicalOperation();
23 StartLogicalOperation();
24
21 25 Trace.WriteLine("Inner");
22 26 foreach(var x in Trace.CorrelationManager.LogicalOperationStack)
23 27 Trace.WriteLine($"-{x}");
24 source.TraceEvent(TraceEventType.Information, 1, "source event");
28 Log("source event");
29
30 listener.IndentLevel = 1;
31
25 32 source.TraceData(TraceEventType.Start, 1, DateTime.Now);
26 Trace.CorrelationManager.StopLogicalOperation();
33
34 StopLogicalOperation();
27 35 }
28 36 }
29 37 }
@@ -48,16 +48,8 namespace Implab.Components {
48 48 }
49 49 }
50 50
51 /// <summary>
52 /// Записывает сообщение об утечке объекта.
53 /// </summary>
54 protected virtual void ReportObjectLeaks() {
55 TraceLog.TraceWarning("The object is marked as disposable but isn't disposed properly: {0}", this);
56 }
57
58 51 ~Disposable() {
59 52 Dispose(false);
60 ReportObjectLeaks();
61 53 }
62 54 }
63 55 } No newline at end of file
@@ -15,7 +15,7 namespace Implab.Components {
15 15 public class RunnableComponent : IRunnable, IInitializable, IDisposable {
16 16
17 17 /// <summary>
18 /// This class bound <see cref="CancellationTokenSource"/> lifetime to the task,
18 /// This class bounds <see cref="CancellationTokenSource"/> lifetime to the task,
19 19 /// when the task completes the associated token source will be disposed.
20 20 /// </summary>
21 21 class AsyncOperationDescriptor {
@@ -161,7 +161,7 namespace Implab.Components {
161 161 /// <remarks>
162 162 /// This method should be used for short and mostly syncronous operations,
163 163 /// other operations which require time to run shoud be placed in
164 /// <see cref="StartInternal(CancellationToken)"/> method.
164 /// <see cref="StartInternalAsync(CancellationToken)"/> method.
165 165 /// </remarks>
166 166 protected virtual Task InitializeInternalAsync(CancellationToken ct) {
167 167 return Task.CompletedTask;
@@ -170,10 +170,10 namespace Implab.Components {
170 170 public void Start(CancellationToken ct) {
171 171 var cookie = new object();
172 172 if (MoveStart(cookie))
173 ScheduleTask(StartInternal, ct, cookie);
173 ScheduleTask(StartInternalAsync, ct, cookie);
174 174 }
175 175
176 protected virtual Task StartInternal(CancellationToken ct) {
176 protected virtual Task StartInternalAsync(CancellationToken ct) {
177 177 return Task.CompletedTask;
178 178 }
179 179
@@ -8,10 +8,10 using System.Threading.Tasks;
8 8 namespace Implab.Diagnostics {
9 9 public static class Trace<T> {
10 10
11 readonly static LogChannel<TraceEvent> _channel = new LogChannel<TraceEvent>(typeof(T).Name);
11 readonly static TraceSource _traceSource = new TraceSource(typeof(T).Name);
12 12
13 public static LogChannel<TraceEvent> Channel {
14 get { return _channel; }
13 public static TraceSource TraceSource {
14 get { return _traceSource; }
15 15 }
16 16
17 17 /// <summary>
@@ -19,7 +19,7 namespace Implab.Diagnostics {
19 19 /// </summary>
20 20 [Conditional("TRACE")]
21 21 public static void StartLogicalOperation() {
22 TraceContext.Instance.StartLogicalOperation();
22 Trace.CorrelationManager.StartLogicalOperation();
23 23
24 24 }
25 25
@@ -29,17 +29,15 namespace Implab.Diagnostics {
29 29 /// <param name="name">Name.</param>
30 30 [Conditional("TRACE")]
31 31 public static void StartLogicalOperation(string name) {
32 Channel.LogEvent(new TraceEvent(TraceContext.Instance.CurrentOperation, TraceEventType.OperationStarted, name));
33 TraceContext.Instance.StartLogicalOperation(name);
32 Trace.CorrelationManager.StartLogicalOperation();
34 33 }
35 34
36 35 /// <summary>
37 36 /// Ends the logical operation and restores the previous one.
38 37 /// </summary>
39 38 [Conditional("TRACE")]
40 public static void EndLogicalOperation() {
41 var op = TraceContext.Instance.EndLogicalOperation();
42 Channel.LogEvent(new TraceEvent(op, TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms", op.Name, op.Duration)));
39 public static void StopLogicalOperation() {
40 Trace.CorrelationManager.StopLogicalOperation();
43 41 }
44 42
45 43 /// <summary>
@@ -49,7 +47,7 namespace Implab.Diagnostics {
49 47 /// <param name="arguments">Arguments.</param>
50 48 [Conditional("TRACE")]
51 49 public static void Log(string format, params object[] arguments) {
52 Channel.LogEvent(TraceEvent.Create(TraceContext.Instance.CurrentOperation, TraceEventType.Information, format, arguments));
50 TraceSource.TraceEvent(TraceEventType.Information, 1, format, arguments);
53 51 }
54 52
55 53 /// <summary>
@@ -59,17 +57,17 namespace Implab.Diagnostics {
59 57 /// <param name="arguments">Arguments.</param>
60 58 [Conditional("TRACE")]
61 59 public static void Warn(string format, params object[] arguments) {
62 Channel.LogEvent(TraceEvent.Create(TraceContext.Instance.CurrentOperation, TraceEventType.Warning, format, arguments));
60 TraceSource.TraceEvent(TraceEventType.Warning, 1, format, arguments);
63 61 }
64 62
65 63 [Conditional("TRACE")]
66 64 public static void Error(string format, params object[] arguments) {
67 Channel.LogEvent(TraceEvent.Create(TraceContext.Instance.CurrentOperation, TraceEventType.Error, format, arguments));
65 TraceSource.TraceEvent(TraceEventType.Error, 1, format, arguments);
68 66 }
69 67
70 68 [Conditional("TRACE")]
71 69 public static void Error(Exception err) {
72 Error("{0}", err);
70 TraceSource.TraceData(TraceEventType.Error, 1, err);
73 71 }
74 72 }
75 73 }
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
1 NO CONTENT: file was removed
General Comments 3
Under Review
author

Auto status change to "Under Review"

Approved
author

ok, latest stable version should be in default

You need to be logged in to leave comments. Login now