using System.Diagnostics;

namespace XGame.Framework.Asset
{
    internal static class AssetsLog
    {
        private static bool _isOpen = true;
        private static readonly string _head = "[Assets]";

        [Conditional(MacroDefine.UNITY_EDITOR)]
#if !PROFILER
        [Conditional(MacroDefine.DEBUG)]
#endif
        public static void Debug(string format, params object[] args)
        {
            if (_isOpen)
            {
                Log.Debug($"{_head} {Format(format, args)}");
            }
        }

        [Conditional(MacroDefine.UNITY_EDITOR), Conditional(MacroDefine.DEBUG), Conditional(MacroDefine.PROFILER), Conditional(MacroDefine.FINAL_RELEASE)]
        public static void Info(string format, params object[] args)
        {
            if (_isOpen)
            {
                Log.Info($"{_head} {Format(format, args)}");
            }
        }

        [Conditional(MacroDefine.UNITY_EDITOR), Conditional(MacroDefine.DEBUG), Conditional(MacroDefine.PROFILER)]
        public static void Warn(string format, params object[] args)
        {
            if (_isOpen)
            {
                Log.Warn($"{_head} {Format(format, args)}");
            }
        }

        public static void Error(string format, params object[] args)
        {
            Log.Error($"{_head} {Format(format, args)}");
        }
        public static void Exception(System.Exception exception)
        {
            Log.Exception(_head, exception);
        }

        private static string Format(string format, params object[] args)
        {
            if (args == null || args.Length <= 0)
                return format;
            else
                return string.Format(format, args);
        }
    }
}
