Beispiel #1
0
        /// <summary>
        /// Write to text file, file is rolled.
        /// </summary>
        /// <param name="source">Event source.</param>
        /// <param name="fileNameSelector">Selector of output file name. DateTime is date of file open time, int is number sequence.</param>
        /// <param name="timestampPattern">Pattern of rolling identifier. DateTime is write time of message. If pattern is different roll new file.</param>
        /// <param name="rollSizeKB">Size of start next file.</param>
        /// <param name="messageFormatter">Converter of message per line.</param>
        /// <param name="encoding">String encoding.</param>
        /// <param name="autoFlush">If true, call Flush on every write.</param>
        public static IDisposable LogToRollingFile(this IObservable <IList <TraceEvent> > source, Func <DateTime, int, string> fileNameSelector, Func <DateTime, string> timestampPattern, int rollSizeKB, Func <TraceEvent, string> messageFormatter, Encoding encoding, bool autoFlush)
        {
            var sink         = new TraceEventSink(fileNameSelector, timestampPattern, rollSizeKB, messageFormatter, encoding, autoFlush);
            var subscription = source.Subscribe(sink);

            return(sink.CreateLinkedDisposable(subscription));
        }
Beispiel #2
0
        public static IDisposable LogToConsole(this IObservable <IList <TraceEvent> > source)
        {
            var sink         = new TraceEventSink(x => x.EventName + ": " + x.DumpPayloadOrMessage());
            var subscription = source.Subscribe(sink);

            return(sink.CreateLinkedDisposable(subscription));
        }
Beispiel #3
0
        public static IDisposable LogToConsole(this IObservable <IList <TraceEvent> > source, Func <TraceEvent, string> messageFormatter)
        {
            var sink         = new TraceEventSink(messageFormatter);
            var subscription = source.Subscribe(sink);

            return(sink.CreateLinkedDisposable(subscription));
        }
Beispiel #4
0
        /// <summary>
        /// Write to text file.
        /// </summary>
        /// <param name="source">Event source.</param>
        /// <param name="messageFormatter">Converter of message per line.</param>
        /// <param name="encoding">String encoding.</param>
        /// <param name="autoFlush">If true, call Flush on every write.</param>
        public static IDisposable LogToFile(this IObservable <IList <TraceEvent> > source, string fileName, Func <TraceEvent, string> messageFormatter, Encoding encoding, bool autoFlush)
        {
            var sink         = new TraceEventSink(fileName, messageFormatter, encoding, autoFlush);
            var subscription = source.Subscribe(sink);

            return(sink.CreateLinkedDisposable(subscription));
        }