// Created with MonoDevelop
//
//    Copyright (C) 2017 Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.




using System;
using System.IO;

namespace Hiperscan.FileIO
{
	public partial class LogWriter : StringWriter
	{
		public override void Write (bool value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (char value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (char[] buffer, int index, int count)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(buffer, index, count);
                    this.ConsoleOutput.Write(buffer, index, count);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (decimal value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (double value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (float value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (int value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (long value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (object value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (string value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (string format, object arg0)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(format, arg0);
                    this.ConsoleOutput.Write(format, arg0);
                    }
                catch (Exception) { }
            }
		}
		
		public override void Write (string format, object arg0, object arg1)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(format, arg0, arg1);
                    this.ConsoleOutput.Write(format, arg0, arg1);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (string format, object arg0, object arg1, object arg2)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(format, arg0, arg1, arg2);
                    this.ConsoleOutput.Write(format, arg0, arg1, arg2);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (uint value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
		
		public override void Write (ulong value)
		{
            lock (this)
            {
                try
                {
                    if (this.FileStreamIsOpen == true)
                        this.FileOutput.Write(value);
                    this.ConsoleOutput.Write(value);
                }
                catch (Exception) { }
            }
		}
	}
}

