using System;
using System.Collections.Generic;
using System.Text;

namespace LKFWSClient.WSClient
{
    public enum LKFClientLogLevel : int
    {
        Error = 40,
        Warning = 30,
        Info = 20,
        Debug = 10
    }
    public interface ILKFClientLog
    {
        void AppendLogLine(string text, LKFClientLogLevel logLevel);
    }

    public static class ILKFClientLogExtensions
    {
        public static void Log(this ILKFClientLog log, string text)
        {
            log.AppendLogLine(text, LKFClientLogLevel.Info);
        }

        public static void Error(this ILKFClientLog log, string text)
        {
            log.AppendLogLine(text, LKFClientLogLevel.Error);
        }

        public static void LogException (this ILKFClientLog log, Exception ex)
        {
            while (ex != null)
            {
                log.Error(ex.Message);
                ex = ex.InnerException;
            }
        }
 
        public static void Warning(this ILKFClientLog log, string text)
        {
            log.AppendLogLine(text, LKFClientLogLevel.Warning);
        }

        public static void Debug(this ILKFClientLog log, string text)
        {
            log.AppendLogLine(text, LKFClientLogLevel.Debug);
        }
    }
}

