using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HBLConsole.Service
{
    public class MessageLog
    {
        private volatile static MessageLog _Instance;
        public static MessageLog GetInstance => _Instance ?? (_Instance = new MessageLog());
        private MessageLog() { }

        /// <summary>
        /// 日志显示委托
        /// </summary>
        public Action<string> InfoNotify { get; set; }

        /// <summary>
        /// 日志信息
        /// </summary>
        public string LogInfo { get; set; } = string.Empty;


        public void Show(string info)
        {
            Debug.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")}：{info}");
            LogInfo = $"{DateTime.Now.ToString("HH:mm:ss")}：{info} \n\r {LogInfo}";
            if (InfoNotify != null) InfoNotify(info);
        }

    }
}
