|
1 | 1 | // Licensed to the .NET Foundation under one or more agreements. |
2 | 2 | // The .NET Foundation licenses this file to you under the MIT license. |
3 | 3 |
|
4 | | -using System; |
5 | | - |
6 | | -class Program |
| 4 | +namespace EP_Target |
7 | 5 | { |
8 | | - static void Main() |
| 6 | + using System; |
| 7 | + using System.Diagnostics.Tracing; |
| 8 | + using System.Threading; |
| 9 | + |
| 10 | + public static class Program |
| 11 | + { |
| 12 | + public static void Main(string[] args) |
| 13 | + { |
| 14 | + Console.WriteLine("Waiting 10 seconds to client to get the PID"); |
| 15 | + Thread.Sleep(10 * 1000); |
| 16 | + |
| 17 | + TargetStartLogging(); |
| 18 | + |
| 19 | + Console.WriteLine("Done done!"); |
| 20 | + } |
| 21 | + |
| 22 | + private static void TargetStartLogging() |
| 23 | + { |
| 24 | + DemoEventSource.Log.AppStarted("Hello World From .NET!", 12); |
| 25 | + } |
| 26 | + } |
| 27 | + |
| 28 | + [EventSource(Name = "Demo")] |
| 29 | + class DemoEventSource : EventSource |
9 | 30 | { |
10 | | - Console.WriteLine("Hello world"); |
| 31 | + public static DemoEventSource Log { get; } = new DemoEventSource(); |
| 32 | + |
| 33 | + [Event(1, Keywords = Keywords.Startup)] |
| 34 | + public void AppStarted(string message, int favoriteNumber) => WriteEvent(1, message, favoriteNumber); |
| 35 | + |
| 36 | + [Event(2, Keywords = Keywords.Requests)] |
| 37 | + public void RequestStart(int requestId) => WriteEvent(2, requestId); |
| 38 | + |
| 39 | + [Event(3, Keywords = Keywords.Requests)] |
| 40 | + public void RequestStop(int requestId) => WriteEvent(3, requestId); |
| 41 | + |
| 42 | + [Event(4, Keywords = Keywords.Startup, Level = EventLevel.Verbose)] |
| 43 | + public void DebugMessage(string message) => WriteEvent(4, message); |
| 44 | + |
| 45 | + |
| 46 | + public class Keywords |
| 47 | + { |
| 48 | + public const EventKeywords Startup = (EventKeywords)0x0001; |
| 49 | + public const EventKeywords Requests = (EventKeywords)0x0002; |
| 50 | + } |
11 | 51 | } |
12 | 52 | } |
0 commit comments