/// <summary> /// Returns an observable that traces OnNext, OnError and OnCompleted calls from the specified observable /// and includes an auto-generated identifier in the trace output. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which notifications will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <returns>An observable that traces all notifications.</returns> public static IObservable <T> TraceIdentity <T>(this IObservable <T> source, TraceSource trace) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new IdentifiedTraceObserver <T>(trace))); }
/// <summary> /// Returns an observable that traces a call to OnError from the specified observable. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which the error will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <returns>An observable that traces a call to OnError.</returns> public static IObservable <T> TraceOnError <T>(this IObservable <T> source, TraceSource trace) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new TraceObserver <T>(trace, _ => null, TraceDefaults.DefaultOnError))); }
/// <summary> /// Returns an observable that traces a call to OnError from the specified observable. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which the error will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <param name="messageSelector">A function that returns the message to be traced for the error.</param> /// <returns>An observable that traces a call to OnError.</returns> public static IObservable <T> TraceOnError <T>(this IObservable <T> source, TraceSource trace, Func <Exception, string> messageSelector) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(messageSelector != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new TraceObserver <T>(trace, _ => null, messageSelector))); }
/// <summary> /// Returns an observable that traces OnNext calls from the specified observable. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which notifications will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <param name="format">The format in which values will be traced. A single replacement token {0} is supported.</param> /// <returns>An observable that traces OnNext notifications.</returns> public static IObservable <T> TraceOnNext <T>(this IObservable <T> source, TraceSource trace, string format) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(format != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new TraceObserver <T>(trace, TraceDefaults.GetFormatOnNext <T>(format)))); }
static myClass() { var xml = new System.Diagnostics.XmlWriterTraceListener(System.IO.Directory.GetCurrentDirectory() + "\\ApplicationTrace.svclog"); xml.TraceOutputOptions = System.Diagnostics.TraceOptions.Callstack | System.Diagnostics.TraceOptions.DateTime | System.Diagnostics.TraceOptions.LogicalOperationStack | System.Diagnostics.TraceOptions.ProcessId | System.Diagnostics.TraceOptions.ThreadId | System.Diagnostics.TraceOptions.Timestamp; TraceLogger = new System.Diagnostics.TraceSource("TraceLogger"); TraceLogger.Switch.Level = System.Diagnostics.SourceLevels.All; TraceLogger.Listeners.Add(xml); TraceLogger.Flush(); TraceLogger.Close(); }
void System_Diagnostics_TraceSource_TraceInformation(string[] args) { var ts = new System.Diagnostics.TraceSource("TraceTest"); ts.TraceInformation("0"); // Compliant ts.TraceInformation("{0}", 42); ts.TraceInformation("{0}", args[0], args[1]); // Noncompliant // ^^^^^^^^^^^^^^^^^^^ ts.TraceInformation("{2}", 1, 2, 3); // Noncompliant }
public static IEnumerable <T> TraceOnError <T>(this IEnumerable <T> source, TraceSource trace) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Ensures(Contract.Result <IEnumerable <T> >() != null); var enumerable = source.Do(new TraceObserver <T>(trace, _ => null, TraceDefaults.DefaultOnError)); Contract.Assume(enumerable != null); return(enumerable); }
public static IEnumerable <T> TraceIdentity <T>(this IEnumerable <T> source, TraceSource trace) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Ensures(Contract.Result <IEnumerable <T> >() != null); var enumerable = source.Do(new IdentifiedTraceObserver <T>(trace)); Contract.Assume(enumerable != null); return(enumerable); }
/// <summary> /// Returns an observable that traces OnNext, OnError and OnCompleted calls from the specified observable /// and includes the specified <paramref name="identity"/> in the trace output. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which notifications will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <param name="identity">Identifies the observer in the trace output.</param> /// <returns>An observable that traces all notifications.</returns> public static IObservable <T> TraceIdentity <T>(this IObservable <T> source, TraceSource trace, string identity) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(!string.IsNullOrWhiteSpace(identity)); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new IdentifiedTraceObserver <T>(trace) { Identity = identity })); }
public static IEnumerable <T> TraceOnNext <T>(this IEnumerable <T> source, TraceSource trace, Func <T, string> messageSelector) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(messageSelector != null); Contract.Ensures(Contract.Result <IEnumerable <T> >() != null); var enumerable = source.Do(new TraceObserver <T>(trace, messageSelector)); Contract.Assume(enumerable != null); return(enumerable); }
void System_Diagnostics_TraceSource_TraceInformation(string[] args) { var ts = new System.Diagnostics.TraceSource(""); ts.TraceInformation("0"); ts.TraceInformation("{0}", 42); ts.TraceInformation("{"); // Compliant ts.TraceInformation("[0}", args[0]); // Noncompliant ts.TraceInformation("{-1}", args[0]); // Noncompliant ts.TraceInformation("{0} {1}", args[0]); // Noncompliant ts.TraceInformation(null, "foo", "bar"); // Noncompliant }
private void thread_init() { appTrace = new System.Diagnostics.TraceSource("BrueBoxPosDemo"); if (objListenThread == null) { objListenThread = new System.Threading.Thread(new System.Threading.ThreadStart(thread_start)); } if (objListenThread.ThreadState == System.Threading.ThreadState.Stopped) { objListenThread = new System.Threading.Thread(new System.Threading.ThreadStart(thread_start)); } objListenThread.IsBackground = true; objListenThread.Start(); }
public ConfigDataHandler(string outputManagerID, System.Diagnostics.TraceSource trace) { _trace = trace; _outputManagerID = outputManagerID; ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[schemaName]; string connectionString = settings.ConnectionString; _configDataAccess = PolicyInjection.Create <ConfigDao_Oracle, IConfigDao>(connectionString); UpdateConfiguration(true); ThreadPool.QueueUserWorkItem(UpdateCheckerThread); }
// Add logging using a .Net trace listener private string M2() { try { Person person = new Person() { FirstName = "Raj", LastName = "Konduri" }; var traceSource = new System.Diagnostics.TraceSource("MyLogger"); traceSource.Switch.Level = System.Diagnostics.SourceLevels.All; traceSource.Listeners.Clear(); traceSource.Listeners.Add(new HttpEventCollectorTraceListener(new Uri("http://localhost:8088"), "73f4c508-35da-4d14-9d4b-12a8d820935f")); traceSource.TraceEvent(System.Diagnostics.TraceEventType.Information, 2, JsonConvert.SerializeObject(person)); return("Success"); } catch (Exception ex) { return(ex.Message); } }
public CreateOutputAction() { System.Diagnostics.TraceSource trace = new System.Diagnostics.TraceSource(typeof(CreateOutputAction).Name); trace.Switch.Level = System.Diagnostics.SourceLevels.Error; string loggPath = Path.GetDirectoryName(Imi.Framework.Job.Configuration.InstanceConfig.CurrentInstance.Log.FileName); string loggFile = Path.Combine(loggPath, typeof(CreateOutputAction).FullName + ".log"); Imi.Framework.Shared.Diagnostics.RollingFileTraceListener listener = new Imi.Framework.Shared.Diagnostics.RollingFileTraceListener(loggFile, 512000); trace.Listeners.Add(listener); try { _adapterLockDictionary = new Dictionary <string, ReaderWriterLockSlim>(); _printerLockDictionary = new Dictionary <string, ReaderWriterLockSlim>(); _outputManagerID = ConfigurationManager.AppSettings["OutputManagerID"]; _mainService = Convert.ToBoolean(ConfigurationManager.AppSettings["MainService"]); if (string.IsNullOrEmpty(_outputManagerID)) { trace.TraceEvent(System.Diagnostics.TraceEventType.Error, 0, "\r\n Could not find AppSettings value for OutputManagerID"); } _configDataHandler = ConfigDataAccess.ConfigDataHandler.GetConfigDataHandlerInstance(_outputManagerID, trace); } catch (Exception ex) { trace.TraceEvent(System.Diagnostics.TraceEventType.Error, 0, "\r\n" + ex.Message); } _adapters = new Dictionary <string, IAdapter>(); CreateAdapters(); ThreadPool.QueueUserWorkItem(CheckAndUpdateAdaptersThread); }
/// <summary> /// Returns an observable that traces a call to OnCompleted from the specified observable /// and includes an auto-generated identifier in the trace output. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which the completed notification will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <param name="messageSelector">A function that returns the message to be traced for the completed notification.</param> /// <returns>An observable that traces a call to OnCompleted.</returns> public static IObservable <T> TraceIdentityOnCompleted <T>(this IObservable <T> source, TraceSource trace, Func <string, string> messageSelector) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(messageSelector != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new IdentifiedTraceObserver <T>(trace, (a, b) => null, messageSelector))); }
/// <summary> /// Returns an observable that traces a call to OnCompleted from the specified observable /// and includes an auto-generated identifier in the trace output. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which the completed notification will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <param name="message">The message to be traced for the completed notification.</param> /// <returns>An observable that traces a call to OnCompleted.</returns> public static IObservable <T> TraceIdentityOnCompleted <T>(this IObservable <T> source, TraceSource trace, string message) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(message != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new IdentifiedTraceObserver <T>(trace, (a, b) => null, TraceDefaults.GetIdentityMessageOnCompleted(message)))); }
/// <summary> /// Returns an observable that traces a call to OnError from the specified observable /// and includes an auto-generated identifier in the trace output. /// </summary> /// <typeparam name="T">The object that provides notification information.</typeparam> /// <param name="source">The observable from which the error will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <param name="format">The format in which the error will be traced. A single replacement token {0} is supported.</param> /// <returns>An observable that traces a call to OnError.</returns> public static IObservable <T> TraceIdentityOnError <T>(this IObservable <T> source, TraceSource trace, string format) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(format != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.Do(new IdentifiedTraceObserver <T>(trace, (a, b) => null, TraceDefaults.GetIdentityFormatOnError(format)))); }
public TraceSource(string name = "TraceSourceLogger") { this.Name = name; this._traceSource = new System.Diagnostics.TraceSource(this.Name, System.Diagnostics.SourceLevels.All); }
/// <summary> /// Returns an enumerable that traces a call to OnCompleted from the specified enumerable /// and includes an auto-generated identifier in the trace output. /// </summary> /// <typeparam name="T">Type of object to be enumerated.</typeparam> /// <param name="source">The enumerable from which the completed notification will be traced.</param> /// <param name="trace">The <see cref="TraceSource"/> to be associated with the trace messages.</param> /// <returns>An enumerable that traces a call to OnCompleted.</returns> public static IEnumerable <T> TraceIdentityOnCompleted <T>(this IEnumerable <T> source, TraceSource trace) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Ensures(Contract.Result <IEnumerable <T> >() != null); var enumerable = source.Do(new IdentifiedTraceObserver <T>(trace, (a, b) => null, TraceDefaults.DefaultOnCompleted)); Contract.Assert(enumerable != null); return(enumerable); }
public static IObservable <T> TraceSubscriptions <T>(this IObservable <T> source, TraceSource trace) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(Observable.Create <T>(observer => { trace.TraceInformation(Rxx.Diagnostics.Properties.Text.DefaultSubscribingMessage); var subscription = new CompositeDisposable( Disposable.Create(() => trace.TraceInformation(Rxx.Diagnostics.Properties.Text.DefaultDisposingSubscriptionMessage)), source.SubscribeSafe(observer), Disposable.Create(() => trace.TraceInformation(Rxx.Diagnostics.Properties.Text.DefaultDisposedSubscriptionMessage))); trace.TraceInformation(Rxx.Diagnostics.Properties.Text.DefaultSubscribedMessage); return subscription; })); }
public static IEnumerable <T> TraceIdentityOnNext <T>(this IEnumerable <T> source, TraceSource trace, string format) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(format != null); Contract.Ensures(Contract.Result <IEnumerable <T> >() != null); var enumerable = source.Do(new IdentifiedTraceObserver <T>(trace, TraceDefaults.GetIdentityFormatOnNext <T>(format))); Contract.Assume(enumerable != null); return(enumerable); }
public static IEnumerable <T> TraceIdentityOnError <T>(this IEnumerable <T> source, TraceSource trace, Func <string, Exception, string> messageSelector) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(messageSelector != null); Contract.Ensures(Contract.Result <IEnumerable <T> >() != null); var enumerable = source.Do(new IdentifiedTraceObserver <T>(trace, (a, b) => null, messageSelector)); Contract.Assume(enumerable != null); return(enumerable); }
public static ConfigDataHandler GetConfigDataHandlerInstance(string outputManagerID, System.Diagnostics.TraceSource trace) { if (!string.IsNullOrEmpty(outputManagerID) && trace != null) { _InternalInstance = new ConfigDataHandler(outputManagerID, trace); } return(_InternalInstance); }
public InitializingTraceSourceEventArgs(System.Diagnostics.TraceSource traceSource) { }
public static IObservable <T> TraceSubscriptions <T>(this IObservable <T> source, TraceSource trace, string subscribingMessage, string subscribedMessage, string disposingMessage, string disposedMessage) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(subscribingMessage != null); Contract.Requires(subscribedMessage != null); Contract.Requires(disposingMessage != null); Contract.Requires(disposedMessage != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(Observable.Create <T>(observer => { trace.TraceInformation(subscribingMessage); var subscription = new CompositeDisposable( Disposable.Create(() => trace.TraceInformation(disposingMessage)), source.SubscribeSafe(observer), Disposable.Create(() => trace.TraceInformation(disposedMessage))); trace.TraceInformation(subscribedMessage); return subscription; })); }
public void Trace(TrackingOptions options = TrackingOptions.Default, System.Diagnostics.TraceSource source = null) { //throw new System.NotImplementedException(); }
/// <summary> /// Create trace sources containing multiple listeners with the multiple formats, source levels and fields. /// </summary> /// <param name="creationData">Creation data for TraceSources.</param> /// <param name="name">TraceSource name.</param> /// <returns>TraceSources containing listeners all sharing same format.</returns> private static ICollection<System.Diagnostics.TraceSource> CreateTraceSource(string name, IEnumerable<LogCreationDatum> creationData) { LinkedList<System.Diagnostics.TraceSource> tracesources = new LinkedList<System.Diagnostics.TraceSource>(); foreach (LogCreationDatum creationDatum in creationData) { System.Diagnostics.TraceSource ts = new System.Diagnostics.TraceSource(name); Udbus.Core.Logging.Formatter formatter = new Udbus.Core.Logging.Formatter(creationDatum.format, creationDatum.fields); IEnumerable<System.Diagnostics.TraceListener> listeners = Udbus.Core.Logging.TraceListenerFormat.GenerateTraceListener(formatter, creationDatum.listeners); // Remove OutputDebug listener if not debugging. #if !DEBUG //#if !TRACE ts.Listeners.Remove("Default"); //#endif // !TRACE #endif // !DEBUG // Add listeners. ts.Listeners.AddRange(listeners.ToArray()); ts.Attributes.Add("autoflush", "true"); ts.Attributes.Add("indentsize", "2"); // See System.Diagnostics.SourceLevels. System.Diagnostics.SourceSwitch sourceSwitch = new System.Diagnostics.SourceSwitch(name, creationDatum.sourceLevel.ToString()); ts.Switch = sourceSwitch; tracesources.AddLast(ts); } return tracesources; }
public static IEnumerable <T> TraceOnCompleted <T>(this IEnumerable <T> source, TraceSource trace, string message) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(message != null); Contract.Ensures(Contract.Result <IEnumerable <T> >() != null); var enumerable = source.Do(new TraceObserver <T>(trace, _ => null, TraceDefaults.GetMessageOnCompleted(message))); Contract.Assume(enumerable != null); return(enumerable); }
public static IObservable <T> TraceSubscriptions <T>(this IObservable <T> source, TraceSource trace, string identity) { Contract.Requires(source != null); Contract.Requires(trace != null); Contract.Requires(identity != null); Contract.Ensures(Contract.Result <IObservable <T> >() != null); return(source.TraceSubscriptions( trace, string.Format(CultureInfo.CurrentCulture, Rxx.Diagnostics.Properties.Text.SubscribingFormat, identity), string.Format(CultureInfo.CurrentCulture, Rxx.Diagnostics.Properties.Text.SubscribedFormat, identity), string.Format(CultureInfo.CurrentCulture, Rxx.Diagnostics.Properties.Text.DisposingSubscriptionFormat, identity), string.Format(CultureInfo.CurrentCulture, Rxx.Diagnostics.Properties.Text.DisposedSubscriptionFormat, identity))); }
public static ILog Create(string sourceName) { var traceSource = new System.Diagnostics.TraceSource(sourceName); return new Log(traceSource); }