示例#1
0
        public ConsoleLog(ConsoleLogTarget target, Encoding encoding, int bufferSize, ConsoleLogStyle defaultStyle)
        {
            if (!target.IsValid())
            {
                throw new ArgumentOutOfRangeException(nameof(target));
            }

            if (encoding == null)
            {
                throw new ArgumentNullException(nameof(encoding));
            }

            if (bufferSize < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bufferSize));
            }

            Stream tempStream = null;

            try
            {
                tempStream = OpenStandardStream(target, bufferSize);
                writer     = new StreamWriter(tempStream, encoding, bufferSize);
                tempStream = null;
            }
            finally
            {
                tempStream?.Close();
            }

            this.defaultStyle = defaultStyle;
        }
示例#2
0
 public ConsoleLog(ConsoleLogTarget target, Encoding encoding, ConsoleLogStyle defaultStyle)
     : this(target, encoding, DefaultBufferSize, defaultStyle)
 {
 }
示例#3
0
 public ConsoleLog(ConsoleLogStyle defaultStyle)
     : this(ConsoleLogTarget.Out, Console.OutputEncoding, DefaultBufferSize, defaultStyle)
 {
 }