123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- #region Apache License
- #endregion
- using System;
- using System.IO;
- using log4net.Core;
- namespace log4net.Util
- {
-
-
-
-
-
-
-
-
-
-
-
- public class CountingQuietTextWriter : QuietTextWriter
- {
- #region Public Instance Constructors
-
-
-
-
-
-
-
-
-
-
-
- public CountingQuietTextWriter(TextWriter writer, IErrorHandler errorHandler) : base(writer, errorHandler)
- {
- m_countBytes = 0;
- }
- #endregion Public Instance Constructors
- #region Override implementation of QuietTextWriter
-
-
-
-
-
-
-
-
-
-
-
- public override void Write(char value)
- {
- try
- {
- base.Write(value);
-
-
- m_countBytes += this.Encoding.GetByteCount(new char[] { value });
- }
- catch(Exception e)
- {
- this.ErrorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- public override void Write(char[] buffer, int index, int count)
- {
- if (count > 0)
- {
- try
- {
- base.Write(buffer, index, count);
-
-
- m_countBytes += this.Encoding.GetByteCount(buffer, index, count);
- }
- catch(Exception e)
- {
- this.ErrorHandler.Error("Failed to write buffer.", e, ErrorCode.WriteFailure);
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
- override public void Write(string str)
- {
- if (str != null && str.Length > 0)
- {
- try
- {
- base.Write(str);
-
-
- m_countBytes += this.Encoding.GetByteCount(str);
- }
- catch(Exception e)
- {
- this.ErrorHandler.Error("Failed to write [" + str + "].", e, ErrorCode.WriteFailure);
- }
- }
- }
-
- #endregion Override implementation of QuietTextWriter
- #region Public Instance Properties
-
-
-
-
-
-
-
-
-
-
-
- public long Count
- {
- get { return m_countBytes; }
- set { m_countBytes = value; }
- }
- #endregion Public Instance Properties
-
- #region Private Instance Fields
-
-
-
- private long m_countBytes;
- #endregion Private Instance Fields
- }
- }
|