using System;

namespace VCommon.Logging
{
    public class ConsoleLogger : ILogger
    {
        public void Debug(string summary, object moreInfo) => Console.WriteLine(FormatMessage(nameof(Debug).ToUpper(), summary, moreInfo));

        public void Trace(string summary, object moreInfo) => Console.WriteLine(FormatMessage(nameof(Trace).ToUpper(), summary, moreInfo));

        public void Info(string summary, object moreInfo) => Console.WriteLine(FormatMessage(nameof(Info).ToUpper(), summary, moreInfo));

        public void Warn(string summary, object moreInfo) => Console.WriteLine(FormatMessage(nameof(Warn).ToUpper(), summary, moreInfo));

        public void Error(string summary, object moreInfo) => Console.WriteLine(FormatMessage(nameof(Error).ToUpper(), summary, moreInfo));

        public void Fatal(string summary, object moreInfo) => Console.WriteLine(FormatMessage(nameof(Fatal).ToUpper(), summary, moreInfo));

        protected virtual string FormatMessage(string level, string summary, object moreInfo)
        {
            return $"{level.ToUpper()} -- {summary} {moreInfo}";
        }
    }
}