using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Text;
using System.Diagnostics;

namespace WPLog
{
    public enum LogLevel
    {
        Error = 0,
        Warn = 1,
        Info = 2,
        Verbose = 3
    }
    public class Logger
    {

        public string typeName;
        private const string LOGFORMAT = "{0} class - {1}: ";

        private Logger()
        {
        }

        public Logger(Type type)
        {
            
            typeName= type.Name;
            LogLevel = LogLevel.Error;
            DebugOutput = false;
        }


        public void ClearLog()
        {
            LogSystem.Instance.Write("Log Created Time = " + DateTime.Now.ToString());
        }

        public bool DebugOutput { get; set; }

        public LogLevel LogLevel { get; set; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="line"></param>
        public void Write(string line)
        {
            LogSystem.Instance.Write(
                String.Format(LOGFORMAT, typeName, DateTime.Now.ToString()) +
                line);
            if (DebugOutput)
            {
                Debug.WriteLine(line);
            }
        }
        public void WriteError(string line)
        {
            LogSystem.Instance.Write(
                String.Format(LOGFORMAT, typeName, DateTime.Now.ToString()) +
                line);
        }
        public void WriteWarn(string line)
        {
            if (((int)LogLevel) >= 1)
            {
                LogSystem.Instance.Write(
                    String.Format(LOGFORMAT, typeName, DateTime.Now.ToString()) +
                    line);
                if (DebugOutput)
                {
                    Debug.WriteLine(line);
                }
            }
        }
        public void WriteInfo(string line)
        {
            if (((int)LogLevel) >= 2)
            {
                LogSystem.Instance.Write(
                    String.Format(LOGFORMAT, typeName, DateTime.Now.ToString()) +
                    line);
                if (DebugOutput)
                {
                    Debug.WriteLine(line);
                }
            }
        }
        public void WriteVerbose(string line)
        {
            if (((int)LogLevel) >= 3)
            {
                LogSystem.Instance.Write(
                    String.Format(LOGFORMAT, typeName, DateTime.Now.ToString()) +
                    line);
                if (DebugOutput)
                {
                    Debug.WriteLine(line);
                }
            }
        }

    }
}
