TraceInformation() private method

private TraceInformation ( string message ) : void
message string
return void
Esempio n. 1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            var ts = new TraceSource("rskb.application", SourceLevels.All);
            var di = new SimpleInjector.Container();

            ts.TraceInformation("Build");
            var blackboxfolderpath = ConfigurationManager.AppSettings["blackboxfolderpath"];
            di.RegisterSingle<IBlackBox>(() => new FileBlackBox(blackboxfolderpath));
            di.RegisterSingle(typeof (IBoardPortal), typeof (BoardPortal));
            di.RegisterSingle(typeof(IBoardProvider2), typeof(EventstoreBoardprovider));
            di.RegisterSingle(typeof(IBoard2), typeof(Board2));
            di.RegisterSingle(typeof (IBoardController), typeof (BoardController2));

            var prov = di.GetInstance<IBoardProvider2>();
            var portal = di.GetInstance<IBoardPortal>();
            var ctl = di.GetInstance<IBoardController>();

            ts.TraceInformation("Bind");
            portal.On_card_moved += ctl.Move_card;
            portal.On_new_card += ctl.Create_card;
            portal.On_refresh += ctl.Refresh;

            ctl.On_cards_changed += portal.Display_cards;

            ts.TraceInformation("Run");
            Start(prov, portal);

            ts.TraceInformation("Show");
            Application.Run(portal as Form);
        }
        /// <summary>
        ///	The Agent checks for pending notifications and delivers them to the proper Transport.
        /// Hybrid Agent uses DB (entity) access for the data model.
        /// Transport calls are made by web service.
        /// 
        /// Modifed: 2009-11-1, Jeremy Richardson
        ///		-Fixed issues with local FS when running as a service
        ///		-Added extra exception handling/logging for more robust Service operation
        ///		
        /// Modified: 2010-08-30, John Morgan
        ///     -Changed agent to utilize System.Threading.Timer as opposed to System.Timers.Timer due to exception swallowing
        /// </summary>
        public HybridAgent()
        {
            string traceName = this.GetType().FullName;
            Trace.WriteLine(string.Format("Registering Trace Source {0}.", traceName));
            _Tracer = new TraceSource(traceName);

            System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);
            _Tracer.TraceInformation("Current Directory Set To {0}", System.IO.Directory.GetCurrentDirectory().ToString());

            if (DateTime.Now.TimeOfDay < Settings.Default.ReminderTime.TimeOfDay)
                _LastReminderNotification = DateTime.Now - new TimeSpan(1, 0, 0, 0);
            else
                _LastReminderNotification = DateTime.Now;

            _Tracer.TraceInformation(this.GetType().Assembly.GetName().Version.ToString());
                string configValues = "\r\n---Configuration---";
            configValues += string.Format("Enable Escalation: {0}\r\n", Settings.Default.EnableEscalation);
            configValues += string.Format("Enable Notification: {0}\r\n", Settings.Default.EnableNotification);
            configValues += string.Format("Enable Reminder: {0}\r\n", Settings.Default.EnableReminder);
            configValues += string.Format("Escalation Repeat Timeout: {0}\r\n", Settings.Default.EscalationRepeatTimeout);
            configValues += string.Format("Escalation Transport Name: {0}\r\n", Settings.Default.EscalationTransportName);
            configValues += string.Format("Critical Results URI: {0}\r\n", Settings.Default.CriticalResultsUri);
            configValues += string.Format("Reminder Time: {0}\r\n", Settings.Default.ReminderTime);
            configValues += string.Format("Reminder Transport: {0}\r\n", Settings.Default.ReminderTransportName);
            configValues += string.Format("Timer Interval: {0}\r\n", Settings.Default.TimerInterval);
            configValues += "---Configuration End---";
            _Tracer.TraceInformation(configValues);

            System.Threading.TimerCallback timerCallback = this.OnTimerElapsed;
            _Timer = new System.Threading.Timer(timerCallback, null, 0, _TimerInterval);
            //_Timer.Interval = Settings.Default.TimerInterval.TotalMilliseconds;
            //_Timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed);
            //_Timer.Start();
        }
Esempio n. 3
0
        private static async Task RunSampleAsync(CleanupGuard guard, TraceSource traceSource, CancellationToken token)
        {
            // Make sure we switch to another thread before starting the work.
            await Task.Yield();

            string timestamp = DateTime.Now.ToString("yyyyMMhhmmss");
            string filePrefix = Environment.ExpandEnvironmentVariables(@"%TEMP%\CleanupSample." + timestamp + ".");
            Random random = new Random();
            char[] alphabet = new char[] { 'z', 'x', 'c', 'v', 'b', 'n', 'm' };

            int index = 0;
            while (!token.IsCancellationRequested)
            {
                string fileName = filePrefix + index + ".txt";
                guard.Register(() => ZeroFileAsync(fileName, traceSource));

                traceSource.TraceInformation("Writing file '{0}'...", fileName);
                await WriteFileAsync(fileName, random, alphabet, token);

                traceSource.TraceInformation("Starting 'notepad.exe {0}'...", fileName);
                Process process = Process.Start("notepad.exe", fileName);
                guard.Register(Blocking.Task(KillProcess, Tuple.Create(process, traceSource)));

                traceSource.TraceInformation("Waiting...");
                await Task.Delay(3000, token);

                ++index;
            }
        }
        public SimpleEmailer(string host, int port, string userName, string password, string domain, bool useSsl, string fromAddress, string fromName)
        {
            string traceName = this.GetType().FullName;
            Trace.WriteLine(string.Format("Creating TraceSource {0}.  Please register a listener for detailed information.", traceName));
            _Trace = new TraceSource(traceName);

            _Trace.TraceInformation("Creating SmtpTransport: UserName:{0}, Password: -, Domain:{1}, Host:{2}, Port:{3}, SSL:{4}", userName, domain, host, port, useSsl);

            _Client = new SmtpClient(host,port);
            _Trace.TraceInformation("Created SMTP Client - {0}:{1}", host, port);

            _Client.EnableSsl = useSsl;

            _From = new MailAddress(fromAddress, fromName);
            _Trace.TraceInformation("From address set to {0} [{1}]", _From.Address, _From.DisplayName);

            if (!string.IsNullOrEmpty(userName))
            {
                _Client.UseDefaultCredentials = false;
                _Client.Credentials = new System.Net.NetworkCredential(userName, password, domain);
                _Trace.TraceInformation("Created credentials for {0}\\{1}", domain, userName);
            }
            else
            {
                _Client.UseDefaultCredentials = true;
                _Trace.TraceInformation("Using default credentials");
            }
        }
        /// <summary>
        /// Sets the trace source for all instances of <see cref="EFTracingConnection"/>.
        /// </summary>
        /// <param name="connection">The connection.</param>
        /// <param name="traceSource">The trace source to which to trace SQL command activity.</param>
        public static void SetTraceSource(this DbConnection connection, TraceSource traceSource)
        {
            Contract.Requires(connection != null);
            Contract.Requires(traceSource != null);

            foreach (var tracingConnection in connection.GetTracingConnections())
            {
                tracingConnection.CommandExecuting += (_, e) => traceSource.TraceInformation(e.ToFlattenedTraceString());
                tracingConnection.CommandFinished += (_, e) => traceSource.TraceInformation(e.ToFlattenedTraceString());
                tracingConnection.CommandFailed += (_, e) => traceSource.TraceEvent(TraceEventType.Error, 0, e.ToFlattenedTraceString());
            }
        }
Esempio n. 6
0
        public Tracing(TraceSource traceSource, string name)
        {
            _traceSource = traceSource;
            _name = name;

            _traceSource.TraceInformation(string.Format("Entering {0}", _name));
        }
		static TraceSource CreateSource(string name)
		{
			var source = new TraceSource(name);
			// The source.Listeners.Count call causes the tracer to be initialized from config at this point.
			source.TraceInformation("Initialized trace source {0} with initial level {1} and {2} initial listeners.", name, source.Switch.Level, source.Listeners.Count);
			
			return source;
		}
Esempio n. 8
0
        public void ConfigTest()
        {
            var source = new TraceSource("MSMQTEST", SourceLevels.All);

            source.TraceInformation("test1");

            source.TraceEvent(TraceEventType.Error, 1, "Test 2 {0}", 123);
        }
Esempio n. 9
0
 private static async Task ZeroFileAsync(string fileName, TraceSource traceSource)
 {
     traceSource.TraceInformation("Zeroing out file '{0}'...", fileName);
     using (FileStream stream = CreateAsyncStream(fileName))
     {
         await stream.WriteAsync(new byte[0], 0, 0);
     }
 }
Esempio n. 10
0
 public virtual void TraceInformation(string format, params object[] args)
 {
     Execute(() =>
     {
         args = enricher.Enrich(args);
         traceSource.TraceInformation(format, args);
     });
 }
Esempio n. 11
0
 private void TraceToOutput()
 {
     TraceSource traceSource = new TraceSource("TraceSource", SourceLevels.All);
     traceSource.TraceInformation("Tracing");
     traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical");
     traceSource.TraceData(TraceEventType.Information, 1, new object[] { "x", "y", "z" });
     traceSource.Flush();
     traceSource.Close();
 }
Esempio n. 12
0
        public void Application_Start(object sender, EventArgs e)
        {
            Trace = new TraceSource("Global", SourceLevels.All);
            Trace.Listeners.Add(SignalRTraceListener);
            Storage.Trace.Listeners.Add(SignalRTraceListener);

            RouteTable.Routes.MapHubs();

            Trace.TraceInformation("Application Starting");
        }
Esempio n. 13
0
        public static void TraceStack(TraceSource file)
        {
            StackTrace stackTrace = new StackTrace();

            if (file != null && stackTrace.FrameCount > 0)
            {
                file.TraceInformation("_________________________________________");

                file.TraceInformation("StackTrace:");

                for (int i = 0; i < stackTrace.FrameCount; i++)
                {
                    string frame = string.Empty;

                    if (stackTrace.GetFrame(i).GetMethod() != null && stackTrace.GetFrame(i).GetMethod().DeclaringType != null)
                    {
                        frame = "\t" + stackTrace.GetFrame(i).GetMethod().DeclaringType.ToString() +
                            "." + stackTrace.GetFrame(i).GetMethod().Name;
                        //file.TraceInformation("." + stackTrace.GetFrame(i).GetMethod().Name);

                        ParameterInfo[] parameters = stackTrace.GetFrame(i).GetMethod().GetParameters();

                        if (parameters != null && parameters.Length > 0)
                        {
                            frame += "( ";

                            foreach (ParameterInfo pi in parameters)
                            {
                                frame += pi.ParameterType + " " + pi.Name + ", ";
                            }

                            frame += " )";
                        }

                        file.TraceInformation(frame);

                        file.TraceInformation("");
                    }
                }
                file.TraceInformation("_________________________________________");
            }
        }
Esempio n. 14
0
        public static void HowToUseTheTraceSourceClass()
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing app");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
Esempio n. 15
0
        public static void Main(string[] args)
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing application...");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
        public void CanLogFromTraceSourceInformation()
        {
            var logMessage = "a simple message";
            var traceSource = new TraceSource("test", SourceLevels.All);
            traceSource.Listeners.Clear();
            traceSource.Listeners.Add(_traceListener);

            traceSource.TraceInformation(logMessage);

            LogEventAssert.HasLevel(LogEventLevel.Information, _loggedEvent);
            LogEventAssert.HasPropertyValue(logMessage, "TraceMessage", _loggedEvent);
        }
    void FormatMethodTests()
    {
        // GOOD: Not a recognised format method.
        Format("}", 0);

        // BAD: All of these are format methods with an invalid string.
        String.Format("}", 0);
        String.Format("}", ps);
        String.Format(fp, "}", ps);
        String.Format("}", 0, 1);
        String.Format("}", 0, 1, 2);
        String.Format("}", 0, 1, 2, 3);

        sb.AppendFormat("}", 0);
        sb.AppendFormat("}", ps);
        sb.AppendFormat(fp, "}", ps);
        sb.AppendFormat("}", 0, 1);
        sb.AppendFormat("}", 0, 1, 2);
        sb.AppendFormat("}", 0, 1, 2, 3);

        Console.WriteLine("}", 0);
        Console.WriteLine("}", ps);
        Console.WriteLine("}", 0, 1);
        Console.WriteLine("}", 0, 1, 2);
        Console.WriteLine("}", 0, 1, 2, 3);

        tw.WriteLine("}", 0);
        tw.WriteLine("}", ps);
        tw.WriteLine("}", 0, 1);
        tw.WriteLine("}", 0, 1, 2);
        tw.WriteLine("}", 0, 1, 2, 3);

        System.Diagnostics.Debug.WriteLine("}", ps);
        System.Diagnostics.Trace.TraceError("}", 0);
        System.Diagnostics.Trace.TraceInformation("}", 0);
        System.Diagnostics.Trace.TraceWarning("}", 0);
        ts.TraceInformation("}", 0);

        Console.Write("}", 0);
        Console.Write("}", 0, 1);
        Console.Write("}", 0, 1, 2);
        Console.Write("}", 0, 1, 2, 3);

        System.Diagnostics.Debug.WriteLine("}", ""); // GOOD
        System.Diagnostics.Debug.Write("}", "");     // GOOD

        System.Diagnostics.Debug.Assert(true, "Error", "}", ps);
        sw.Write("}", 0);
        System.Diagnostics.Debug.Print("}", ps);

        Console.WriteLine("}"); // GOOD
    }
Esempio n. 18
0
        private void ConnectDiagnosticListeners()
        {
            Console.WriteLine("Trying to connect to the System.ServiceModel trace source.");
            traceListener = new ConsoleTraceListener(false);
            TraceSource serviceModelTraceSource = new TraceSource("System.ServiceModel");
            serviceModelTraceSource.Listeners.Add(traceListener);
            serviceModelTraceSource.TraceInformation("Test information from the host form \r\n");

            TraceSource commonTraceSource = new TraceSource("Tools.Common");
            commonTraceSource.Listeners.Add(traceListener);
            commonTraceSource.TraceInformation("Test information from the Tools.Common \r\n");

        }
Esempio n. 19
0
 public static void DoTrace()
 {
     Stream outputFile = File.Create("tracefile.txt");
     TextWriterTraceListener textListener =
     new TextWriterTraceListener(outputFile);
     TraceSource traceSource = new TraceSource("myTraceSource",
     SourceLevels.All);
     traceSource.Listeners.Clear();
     traceSource.Listeners.Add(textListener);
     traceSource.TraceInformation("Trace output");
     traceSource.Flush();
     traceSource.Close();
 }
Esempio n. 20
0
        private void TraceToFile()
        {
            Stream TrFile = File.Create("Hello_Debug_Trace.txt");
            TextWriterTraceListener txtLstnr =
                new TextWriterTraceListener(TrFile);

            TraceSource traceSource = new
                TraceSource("TraceSource", SourceLevels.All);
            traceSource.Listeners.Clear();
            traceSource.Listeners.Add(txtLstnr);
            traceSource.TraceInformation("Trace output");
            traceSource.Flush();
            traceSource.Close();
        }
Esempio n. 21
0
        static void Main(string[] args)
        {
            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.TraceInformation("Tracing application.");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();

            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }
Esempio n. 22
0
            CalcEdge(int iEdge, int iNode, double Pin, double Qliq, double WCT, FluidInfo fluid, bool addEdgeInfo = true)
            {
                if (addEdgeInfo)
                {
                    resEdgeInfo.Add(iEdge, new EdgeInfo(Q: Qliq, WCT: WCT, f: fluid));
                }

                var e = edges[iEdge];

                var(iNextNode, direction) = e.Next(iNode);

                var Pout = double.NaN;

                if (!double.IsNaN(Pin) && !fluid.IsEmpty)
                {
                    var root = fluid.GetPvtContext();
                    var ctx  = root.NewCtx()
                               .With(PVT.Prm.P, U.Atm2MPa(Pin))
                               .Done();

                    var gd  = new Gradient.DataInfo();
                    var GOR = root[PVT.Arg.Rsb]; // todo: what with GOR ?

                    try
                    {
                        var angleDeg = e.GetAngleDeg(nodes) * direction;
                        var P_MPa    = PressureDrop.dropLiq(ctx, gd,
                                                            D_mm: e.D, L0_m: 0, L1_m: e.L,
                                                            Roughness: 0.0,
                                                            flowDir: (PressureDrop.FlowDirection)direction,
                                                            P0_MPa: ctx[PVT.Prm.P], Qliq, WCT, GOR,
                                                            dL_m: 20, dP_MPa: 1e-4, maxP_MPa: 60, stepHandler: stepHandler, (iEdge + 1) * direction,
                                                            getTempK: (Qo, Qw, L) => 273 + 20,
                                                            getAngle: _ => angleDeg,
                                                            gradCalc: Gradient.BegsBrill.Calc,
                                                            WithFriction: false
                                                            );
                        Pout = U.MPa2Atm(P_MPa);
                    }
                    catch (Exception ex)
                    {
                        var cn = nodes[iNode];
                        var nn = nodes[iNextNode];
                        Logger.TraceInformation($"Error calc for edge A->B\tNodeA={cn.Node_ID}\tNodeB={nn.Node_ID}\tP={ctx[PVT.Prm.P]}\tQ={Qliq}\tEx={ex.Message}");
                    }
                }
                UpdateNodeInfo(iNextNode, Pout);
                return(iNextNode, Pout);
            }
Esempio n. 23
0
        static void Main(string[] args)
        {
            TraceSource ts = new TraceSource("server");
            ts.Switch.Level = SourceLevels.All;
            ts.Listeners.Add(new ConsoleTraceListener());
            Startup.DefaultTraceSource = ts;

            try
            {
                // parse args and start up the server
                string serverUrl = "https://+:25427"; // default url
                if (args != null && args.Length >= 1)
                    serverUrl = args[0];

                // setup
                StartOptions owinSettings = new StartOptions();
                ts.TraceInformation("Starting web server...");
                owinSettings.Urls.Add(serverUrl);
                foreach (var url in owinSettings.Urls)
                {
                    ts.TraceInformation(" - URL: " + url);
                }

                // start
                using(WebApp.Start<Startup>(owinSettings))
                {
                    Console.WriteLine("Server started.");
                    Console.WriteLine("Press [Enter] to exit...");
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                ts.TraceEvent(TraceEventType.Critical, 0, "\nERROR:\n" + e.ToString());
            }
        }
Esempio n. 24
0
        protected ServiceHubServiceBase(Stream stream, IServiceProvider serviceProvider)
        {
            InstanceId = Interlocked.Add(ref s_instanceId, 1);

            Logger = (TraceSource)serviceProvider.GetService(typeof(TraceSource));
            Logger.TraceInformation($"{DebugInstanceString} Service instance created");

            Stream = stream;

            _cancellationTokenSource = new CancellationTokenSource();
            CancellationToken = _cancellationTokenSource.Token;

            Rpc = JsonRpc.Attach(stream, this);
            Rpc.Disconnected += OnRpcDisconnected;
        }
Esempio n. 25
0
        protected ServiceHubServiceBase(Stream stream, IServiceProvider serviceProvider)
        {
            _instanceId = Interlocked.Add(ref s_instanceId, 1);

            // in unit test, service provider will return asset storage, otherwise, use the default one
            AssetStorage = (AssetStorage)serviceProvider.GetService(typeof(AssetStorage)) ?? AssetStorage.Default;

            Logger = (TraceSource)serviceProvider.GetService(typeof(TraceSource));
            Logger.TraceInformation($"{DebugInstanceString} Service instance created");

            _cancellationTokenSource = new CancellationTokenSource();
            CancellationToken = _cancellationTokenSource.Token;

            Rpc = JsonRpc.Attach(stream, this);
            Rpc.Disconnected += OnRpcDisconnected;
        }
Esempio n. 26
0
        public static void HowToUseTheTraceListenerClass()
        {
            Stream outputFile = File.Create("traceFile.txt");
            TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);

            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.Listeners.Clear();
            traceSource.Listeners.Add(textListener);

            traceSource.TraceInformation("Tracing app");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1, new object[] { "a", "b", "c" });

            traceSource.Flush();
            traceSource.Close();
        }
Esempio n. 27
0
        static void Main(string[] args)
        {
            using (Stream outputFile = File.Create("tracefile.txt"))
            {
                TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);

                TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

                traceSource.Listeners.Clear();
                traceSource.Listeners.Add(textListener);

                traceSource.TraceInformation("trace output");

                traceSource.Flush();
                traceSource.Close();
            }
        }
Esempio n. 28
0
        public void MsmqTraceListenerTest()
        {
            var path = @"FormatName:DIRECT=OS:.\private$\test2";
            path = @".\private$\test2";

            var listener = new MsmqTraceListener(path);

            listener = xSolon.TraceListeners.Extensions.Wrap<MsmqTraceListener>(listener);

            var source = new TraceSource("MSMQTEST1", SourceLevels.All);

            source.Listeners.Add(listener);
            source.Listeners.Add(new ConsoleTraceListener());

            source.TraceInformation("test1");

            source.TraceEvent(TraceEventType.Information, 1, "Test 2 {0}", 123);
        }
Esempio n. 29
0
        static void Main(string[] args)
        {
            Stream outputFile = File.Create("tracefile.txt");
            TextWriterTraceListener textListener = new TextWriterTraceListener(outputFile);

            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);

            traceSource.Listeners.Clear();
            traceSource.Listeners.Add(textListener);

            traceSource.TraceInformation("Trace output");

            traceSource.Flush();
            traceSource.Close();

            Console.WriteLine("tracefile.txt created in output directory.");
            Console.WriteLine("Press a key to exit");
            Console.ReadKey();
        }
Esempio n. 30
0
        static void Main(string[] args)
        {
            Debug.WriteLine("Starting application");
            Debug.Indent();
            int i = 1 + 2;
            Debug.Assert(i == 3);
            Debug.WriteLineIf(i > 0, "i is greater than 0");

            TraceSource traceSource = new TraceSource("myTraceSource", SourceLevels.All);
            traceSource.TraceInformation("Tracing application..");
            traceSource.TraceEvent(TraceEventType.Critical, 0, "Critical trace");
            traceSource.TraceData(TraceEventType.Information, 1,
            new object[] { "a", "b", "c" });
            traceSource.Flush();
            traceSource.Close();

            DoTrace();

            Console.ReadLine();
        }
Esempio n. 31
0
        public void when_tracing_via_hub_then_client_gets_trace()
        {
            var traces = new List<TraceEvent>();
            var source = new TraceSource("Source", SourceLevels.Information);
            using (var listener = new RealtimeTraceListener("Test"))
            {
                source.Listeners.Add(listener);

                var data = new Dictionary<string, string>
                {
                    { "groupName", "Test" }
                };

                using (var hub = new HubConnection(TracerHubUrl, data))
                {
                    IHubProxy proxy = hub.CreateHubProxy(HubName);
                    proxy.On<TraceEvent>("TraceEvent", trace => traces.Add(trace));

                    hub.Start().Wait();

                    source.TraceInformation("Foo");

                    var watch = Stopwatch.StartNew();
                    var timeout = TimeSpan.FromSeconds(2);
                    while (watch.Elapsed < timeout)
                    {
                        Thread.Sleep(100);
                    }

                    Assert.Equal(1, traces.Count);
                    Assert.Equal(TraceEventType.Information, traces[0].EventType);
                    Assert.Equal("Source", traces[0].Source);
                    Assert.Equal("Foo", traces[0].Message);
                }
            }
        }
Esempio n. 32
0
 private TraceSource CreateSource(string name)
 {
     var source = new TraceSource(name);
     source.TraceInformation("Initialized trace source {0} with initial level {1}", name, source.Switch.Level);
     return source;
 }
Esempio n. 33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TraceLogger" /> class.
 /// </summary>
 /// <param name="source">The source.</param>
 public TraceLogger(TraceSource source)
     : base(x => source.TraceInformation(x))
 {
     Guard.NotNull(source);
 }