/// <summary> /// Writes a character to the text stream. /// </summary> /// <param name="value">The character to write to the text stream. /// </param><exception cref="T:System.ObjectDisposedException">The <see cref="T:System.IO.TextWriter"/> is closed. /// </exception><exception cref="T:System.IO.IOException">An I/O error occurs. /// </exception><filterpriority>1</filterpriority> /// <remarks> /// TODO: At some point we want to overhaul this to override at the Write(string) and WriteLine() level instead /// of Write(char) and pass the data in a different, stream-optimized format rather than as log messages. /// But for now... Wrap as a log message for each line (as we get a newline).... /// </remarks> public override void Write(char value) { m_OriginalWriter.Write(value); if (value == '\n') { if (m_Buffer.Length > 0) { #if STACK_DUMP Exception dumpException = new GibraltarStackInfoException(m_OutputCategory + " - Write()", null); #else const Exception dumpException = null; #endif SimpleLogMessage logMessage = new SimpleLogMessage(LogMessageSeverity.Verbose, LogWriteMode.Queued, ConsoleLogSystem, m_OutputCategory, 3, dumpException, m_Buffer.ToString()); m_Buffer.Length = 0; logMessage.PublishToLog(); } } else if (value != '\r') { m_Buffer.Append(value); } /* else * m_buffer.Append("<CR>"); */ }
/// <summary> /// Clears all buffers for the current writer and causes any buffered data to be written to the underlying device. /// </summary> /// <filterpriority>1</filterpriority> public override void Flush() { base.Flush(); // Flush our base to push any pending writes to us? m_OriginalWriter.Flush(); // Then flush the original writer for whatever we passed on to it. //m_buffer.Append("<Flush>"); // Now should we go ahead and push any partial lines in a log message? if (m_Buffer.Length > 0) { #if STACK_DUMP Exception dumpException = new GibraltarStackInfoException(m_OutputCategory + " - Flush()", null); #else const Exception dumpException = null; #endif SimpleLogMessage logMessage = new SimpleLogMessage(LogMessageSeverity.Verbose, LogWriteMode.Queued, ConsoleLogSystem, m_OutputCategory, 1, dumpException, m_Buffer.ToString()); m_Buffer.Length = 0; logMessage.PublishToLog(); } }