Exemplo n.º 1
0
        /// <summary>
        /// Initializes tracing with a custom event source
        /// </summary>
        /// <param name="eventIdSubclass">Custom event ID class</param>
        /// <param name="eventSource">Custom event source</param>
        public static void Initialize(Type eventIdSubclass, string eventSource)
        {
            SetEventLogSource(eventSource);
            I3Trace.initialize_default_sinks();
            RegisterEventMessages(eventIdSubclass);
            var application  = Assembly.GetCallingAssembly();
            var thisAssembly = Assembly.GetAssembly(typeof(TraceLibBase));

            var appInfoBuilder = new StringBuilder();

            appInfoBuilder.AppendLine(String.Format("Application info: {0} [{1}]", application.GetName().Name, application.GetName().Version));
            appInfoBuilder.AppendLine(String.Format("TraceLib info: {0} [{1}]", thisAssembly.GetName().Name, thisAssembly.GetName().Version));
            appInfoBuilder.AppendLine(String.Format("User: {0}", Environment.UserName));
            appInfoBuilder.AppendLine(String.Format("Machine: {0}", Environment.MachineName));
            appInfoBuilder.AppendLine(String.Format("OS: {0}", Environment.OSVersion));
            appInfoBuilder.AppendLine(String.Format(".NET version: {0}", Environment.Version));
            appInfoBuilder.AppendLine(String.Format("Application directory: {0}", Environment.CurrentDirectory));

            WriteRegisteredMessage(EventId.ApplicationInfo, appInfoBuilder.ToString());
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new tracing topic
 /// </summary>
 /// <param name="name">The name of the topic as it will appear in the trace files</param>
 /// <param name="defaultLevel">The default tracing level, set when the topic is created and when the level is reset</param>
 public Topic(string name, int defaultLevel = 60)
 {
     _hdl = I3Trace.initialize_topic(name, defaultLevel);
 }