Auto status change to "Under Review"
| @@ -1,29 +1,37 | |||||
| 1 | using System; | 
             | 
        1 | using System; | |
| 2 | using System.Diagnostics; | 
             | 
        2 | using System.Diagnostics; | |
| 3 | using System.Threading; | 
             | 
        3 | using System.Threading; | |
| 
             | 
        4 | using Implab.Diagnostics; | |||
| 4 | using Xunit; | 
             | 
        5 | using Xunit; | |
| 5 | 
             | 
        6 | |||
| 6 | namespace Implab.Test | 
             | 
        7 | namespace Implab.Test | |
| 7 | { | 
             | 
        8 | { | |
| 
             | 
        9 | using static Trace<UnitTest1>; | |||
| 8 | public class UnitTest1 | 
             | 
        10 | public class UnitTest1 | |
| 9 | { | 
             | 
        11 | { | |
| 10 | [Fact] | 
             | 
        12 | [Fact] | |
| 11 | public void Test1() | 
             | 
        13 | public void Test1() | |
| 12 | { | 
             | 
        14 | { | |
| 13 | var listener = new TextWriterTraceListener(Console.Out); | 
             | 
        15 | var listener = new TextWriterTraceListener(Console.Out); | |
| 14 | 
            
                        var source =  | 
        
             | 
        16 | var source = TraceSource; | |
| 
             | 
        17 | source.Switch.Level = SourceLevels.All; | |||
| 15 | 
             | 
        18 | |||
| 16 | source.Listeners.Add(listener); | 
             | 
        19 | source.Listeners.Add(listener); | |
| 
             | 
        20 | Trace.Listeners.Add(listener); | |||
| 17 | 
             | 
        21 | |||
| 18 | Trace.Listeners.Add(listener); | 
             | 
        |||
| 19 | Trace.WriteLine("Hello!"); | 
             | 
        22 | Trace.WriteLine("Hello!"); | |
| 20 | 
            
                         | 
        
             | 
        23 | StartLogicalOperation(); | |
| 
             | 
        24 | ||||
| 21 | Trace.WriteLine("Inner"); | 
             | 
        25 | Trace.WriteLine("Inner"); | |
| 22 | foreach(var x in Trace.CorrelationManager.LogicalOperationStack) | 
             | 
        26 | foreach(var x in Trace.CorrelationManager.LogicalOperationStack) | |
| 23 | Trace.WriteLine($"-{x}"); | 
             | 
        27 | Trace.WriteLine($"-{x}"); | |
| 24 | source.TraceEvent(TraceEventType.Information, 1, "source event"); | 
             | 
        28 | Log("source event"); | |
| 
             | 
        29 | ||||
| 
             | 
        30 | listener.IndentLevel = 1; | |||
| 
             | 
        31 | ||||
| 25 | source.TraceData(TraceEventType.Start, 1, DateTime.Now); | 
             | 
        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 | ~Disposable() { | 
             | 
        51 | ~Disposable() { | |
| 59 | Dispose(false); | 
             | 
        52 | Dispose(false); | |
| 60 | ReportObjectLeaks(); | 
             | 
        |||
| 61 | } | 
             | 
        53 | } | |
| 62 | } | 
             | 
        54 | } | |
| 63 | } No newline at end of file | 
             | 
        55 | } | |
| @@ -15,7 +15,7 namespace Implab.Components { | |||||
| 15 | public class RunnableComponent : IRunnable, IInitializable, IDisposable { | 
             | 
        15 | public class RunnableComponent : IRunnable, IInitializable, IDisposable { | |
| 16 | 
             | 
        16 | |||
| 17 | /// <summary> | 
             | 
        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 | /// when the task completes the associated token source will be disposed. | 
             | 
        19 | /// when the task completes the associated token source will be disposed. | |
| 20 | /// </summary> | 
             | 
        20 | /// </summary> | |
| 21 | class AsyncOperationDescriptor { | 
             | 
        21 | class AsyncOperationDescriptor { | |
| @@ -161,7 +161,7 namespace Implab.Components { | |||||
| 161 | /// <remarks> | 
             | 
        161 | /// <remarks> | |
| 162 | /// This method should be used for short and mostly syncronous operations, | 
             | 
        162 | /// This method should be used for short and mostly syncronous operations, | |
| 163 | /// other operations which require time to run shoud be placed in | 
             | 
        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 | /// </remarks> | 
             | 
        165 | /// </remarks> | |
| 166 | protected virtual Task InitializeInternalAsync(CancellationToken ct) { | 
             | 
        166 | protected virtual Task InitializeInternalAsync(CancellationToken ct) { | |
| 167 | return Task.CompletedTask; | 
             | 
        167 | return Task.CompletedTask; | |
| @@ -170,10 +170,10 namespace Implab.Components { | |||||
| 170 | public void Start(CancellationToken ct) { | 
             | 
        170 | public void Start(CancellationToken ct) { | |
| 171 | var cookie = new object(); | 
             | 
        171 | var cookie = new object(); | |
| 172 | if (MoveStart(cookie)) | 
             | 
        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 | return Task.CompletedTask; | 
             | 
        177 | return Task.CompletedTask; | |
| 178 | } | 
             | 
        178 | } | |
| 179 | 
             | 
        179 | |||
| @@ -8,10 +8,10 using System.Threading.Tasks; | |||||
| 8 | namespace Implab.Diagnostics { | 
             | 
        8 | namespace Implab.Diagnostics { | |
| 9 | public static class Trace<T> { | 
             | 
        9 | public static class Trace<T> { | |
| 10 | 
             | 
        10 | |||
| 11 | 
            
                    readonly static  | 
        
             | 
        11 | readonly static TraceSource _traceSource = new TraceSource(typeof(T).Name); | |
| 12 | 
             | 
        12 | |||
| 13 | 
            
                    public static  | 
        
             | 
        13 | public static TraceSource TraceSource { | |
| 14 | 
            
                        get { return _ | 
        
             | 
        14 | get { return _traceSource; } | |
| 15 | } | 
             | 
        15 | } | |
| 16 | 
             | 
        16 | |||
| 17 | /// <summary> | 
             | 
        17 | /// <summary> | |
| @@ -19,7 +19,7 namespace Implab.Diagnostics { | |||||
| 19 | /// </summary> | 
             | 
        19 | /// </summary> | |
| 20 | [Conditional("TRACE")] | 
             | 
        20 | [Conditional("TRACE")] | |
| 21 | public static void StartLogicalOperation() { | 
             | 
        21 | public static void StartLogicalOperation() { | |
| 22 | 
            
                        Trace | 
        
             | 
        22 | Trace.CorrelationManager.StartLogicalOperation(); | |
| 23 | 
             | 
        23 | |||
| 24 | } | 
             | 
        24 | } | |
| 25 | 
             | 
        25 | |||
| @@ -29,17 +29,15 namespace Implab.Diagnostics { | |||||
| 29 | /// <param name="name">Name.</param> | 
             | 
        29 | /// <param name="name">Name.</param> | |
| 30 | [Conditional("TRACE")] | 
             | 
        30 | [Conditional("TRACE")] | |
| 31 | public static void StartLogicalOperation(string name) { | 
             | 
        31 | public static void StartLogicalOperation(string name) { | |
| 32 | Channel.LogEvent(new TraceEvent(TraceContext.Instance.CurrentOperation, TraceEventType.OperationStarted, name)); | 
             | 
        32 | Trace.CorrelationManager.StartLogicalOperation(); | |
| 33 | TraceContext.Instance.StartLogicalOperation(name); | 
             | 
        |||
| 34 | } | 
             | 
        33 | } | |
| 35 | 
             | 
        34 | |||
| 36 | /// <summary> | 
             | 
        35 | /// <summary> | |
| 37 | /// Ends the logical operation and restores the previous one. | 
             | 
        36 | /// Ends the logical operation and restores the previous one. | |
| 38 | /// </summary> | 
             | 
        37 | /// </summary> | |
| 39 | [Conditional("TRACE")] | 
             | 
        38 | [Conditional("TRACE")] | |
| 40 | 
            
                    public static void  | 
        
             | 
        39 | public static void StopLogicalOperation() { | |
| 41 | 
            
                         | 
        
             | 
        40 | Trace.CorrelationManager.StopLogicalOperation(); | |
| 42 | Channel.LogEvent(new TraceEvent(op, TraceEventType.OperationCompleted, String.Format("-{0} : {1}ms", op.Name, op.Duration))); | 
             | 
        |||
| 43 | } | 
             | 
        41 | } | |
| 44 | 
             | 
        42 | |||
| 45 | /// <summary> | 
             | 
        43 | /// <summary> | |
| @@ -49,7 +47,7 namespace Implab.Diagnostics { | |||||
| 49 | /// <param name="arguments">Arguments.</param> | 
             | 
        47 | /// <param name="arguments">Arguments.</param> | |
| 50 | [Conditional("TRACE")] | 
             | 
        48 | [Conditional("TRACE")] | |
| 51 | public static void Log(string format, params object[] arguments) { | 
             | 
        49 | public static void Log(string format, params object[] arguments) { | |
| 52 | 
            
                         | 
        
             | 
        50 | TraceSource.TraceEvent(TraceEventType.Information, 1, format, arguments); | |
| 53 | } | 
             | 
        51 | } | |
| 54 | 
             | 
        52 | |||
| 55 | /// <summary> | 
             | 
        53 | /// <summary> | |
| @@ -59,17 +57,17 namespace Implab.Diagnostics { | |||||
| 59 | /// <param name="arguments">Arguments.</param> | 
             | 
        57 | /// <param name="arguments">Arguments.</param> | |
| 60 | [Conditional("TRACE")] | 
             | 
        58 | [Conditional("TRACE")] | |
| 61 | public static void Warn(string format, params object[] arguments) { | 
             | 
        59 | public static void Warn(string format, params object[] arguments) { | |
| 62 | 
            
                         | 
        
             | 
        60 | TraceSource.TraceEvent(TraceEventType.Warning, 1, format, arguments); | |
| 63 | } | 
             | 
        61 | } | |
| 64 | 
             | 
        62 | |||
| 65 | [Conditional("TRACE")] | 
             | 
        63 | [Conditional("TRACE")] | |
| 66 | public static void Error(string format, params object[] arguments) { | 
             | 
        64 | public static void Error(string format, params object[] arguments) { | |
| 67 | 
            
                         | 
        
             | 
        65 | TraceSource.TraceEvent(TraceEventType.Error, 1, format, arguments); | |
| 68 | } | 
             | 
        66 | } | |
| 69 | 
             | 
        67 | |||
| 70 | [Conditional("TRACE")] | 
             | 
        68 | [Conditional("TRACE")] | |
| 71 | public static void Error(Exception err) { | 
             | 
        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 | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
| 1 | NO CONTENT: file was removed | 
             | 
        NO CONTENT: file was removed | 
        
        General Comments 3
    
    
  
  ok, latest stable version should be in default
                      You need to be logged in to leave comments.
                      Login now
                    
                