using System;

namespace XGame.Editor.Build
{
    public static class BuildLog
    {
        public static void Log(string msg)
        {
            UnityEngine.Debug.Log(Convert(msg));
        }
        public static void Log(string format, params object[] args)
        {
            UnityEngine.Debug.Log(Convert(Format(format, args)));
        }
        public static void Warn(string msg)
        {
            UnityEngine.Debug.LogWarning(Convert(msg));
        }
        public static void Warn(string format, params object[] args)
        {
            UnityEngine.Debug.LogWarning(Convert(Format(format, args)));
        }
        public static void Error(string msg)
        {
            UnityEngine.Debug.LogError(Convert(msg));
        }
        public static void Error(string format, params object[] args)
        {
            UnityEngine.Debug.LogError(Convert(Format(format, args)));
        }

        public static void Exception(Exception e)
        {
            UnityEngine.Debug.LogError(Convert($"Exception Message:{e.Message}"));
            UnityEngine.Debug.LogException(e);
        }

        private static string Convert(string msg)
        {
            return $"[XBuild][{DateTime.Now}] {msg}";
        }
        private static string Format(string format, params object[] args)
        {
            if (args == null || args.Length <= 0)
                return format;
            else
                return string.Format(format, args);
        }
    }
}

