系统功能:日志模块

using System.Collections.Generic;
using UnityEngine;


namespace Miss
{
    public enum LogEnum
    {
        None = 1,
        All,
        Log,
        LogError
    }


    public class ColorDefine
    {
        private Dictionary<ColorType, string> ColorDic = new Dictionary<ColorType, string>()
        {
            //蓝
            [ColorType.LanSe] = "#0000FF",
            [ColorType.LanZiSe] = "#9F5F9F",


            //红
            [ColorType.HongSe] = "#FF0000",
            [ColorType.ShanHuHong] = "#FF7F00",
            [ColorType.MuDanHong] = "#FF00FF",


            //黄色
            [ColorType.HuangSe] = "#FFFF00",


            //绿色
            [ColorType.ShenLv] = "#00FF00",


            //金色
            [ColorType.JinSe] = "#CD7F32",
            [ColorType.LiangJinSe] = "#D9D919",


        };

        public string this[ColorType type]
        {
            get { return ColorDic[type]; }
        }
    }


    public enum ColorType
    {
        None = 0,

        #region 蓝色
        /// <summary>
        /// 蓝色
        /// </summary>
        LanSe,
        /// <summary>
        /// 海蓝
        /// </summary>
        LanZiSe,
        #endregion


        #region 红色
        /// <summary>
        /// 红色
        /// </summary>
        HongSe,
        /// <summary>
        /// 珊瑚红
        /// </summary>
        ShanHuHong,
        /// <summary>
        /// 牡丹红
        /// </summary>
        MuDanHong,
        #endregion

        #region 黄色
        /// <summary>
        /// 黄色
        /// </summary>
        HuangSe,
        #endregion

        #region 绿色
        /// <summary>
        /// 绿色
        /// </summary>
        ShenLv,
        #endregion

        #region 金色
        /// <summary>
        /// 金色
        /// </summary>
        JinSe,
        /// <summary>
        /// 亮金色
        /// </summary>
        LiangJinSe
        #endregion

    }

    public static class LogUtilits
    {
        public static LogEnum LogType = LogEnum.All;

        private static ColorDefine m_ColorDefine = new ColorDefine();

        /// <summary>
        /// 报错打印-对象为空
        /// </summary>
        public static void LogErrorObjIsNull()
        {
            Debug.LogError("对象为空,请检查");
        }


        /// <summary>
        /// 报错打印-空容量
        /// </summary>
        public static void LogErrorCountIsZero()
        {
            Debug.LogError("容量数量为0,请检查");
        }

        public static void LogFormat(string content, params string[] args)
        {
            if (LogType == LogEnum.All || LogType == LogEnum.Log)
            {
                Debug.LogFormat(content, args);
            }
        }

        public static void LogErrorFormat(string content, params string[] args)
        {
            if (LogType == LogEnum.All || LogType == LogEnum.LogError)
            {
                Debug.LogErrorFormat(content, args);
            }
        }

        public static void LogColorStr(string content, ColorType type = ColorType.None)
        {
            if (LogType == LogEnum.All || LogType == LogEnum.Log)
            {
                string str = content;
                if (type != ColorType.None)
                {
                    string colorCode = m_ColorDefine[type];
                    str = $":  <color={colorCode}>{content}</color>";
                }
                UnityEngine.Debug.Log(str);
            }
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值