Example #1
0
        public static void Log(string message, LogLevel level = LogLevel.Verbose, LogChannel channel = LogChannel.Debug)
        {
            if (!levels.HasFlag(level))
            {
                return;
            }
            if (!channels.HasFlag(channel))
            {
                return;
            }

            var msg = FormatMessage(message, level, channel);

            if (level.HasFlag(LogLevel.Error))
            {
                Debug.LogError(msg);
            }
            else if (level.HasFlag(LogLevel.Warning))
            {
                Debug.LogWarning(msg);
            }
            else
            {
                Debug.Log(msg);
            }

            LogToolNetwork.Log(msg);

            // foreach(var user in ObjectTool.FindAllObject<ILogUser>()) user.Log(message);
        }
Example #2
0
        protected static string FormatMessage(string message, LogLevel level, LogChannel channel)
        {
            var color = "white";

            switch (level)
            {
            case LogLevel.Warning:  color = "yellow";   break;

            case LogLevel.Error:    color = "red";      break;

            case LogLevel.Info:     color = "cyan";     break;

            case LogLevel.Verbose:  color = "white";    break;

            case LogLevel.Dev:      color = "orange";   break;

            default: break;
            }
            var ccolor = color;

            if (channel.HasFlag(LogChannel.Network))
            {
                ccolor = "green";
            }

            var time = DateTime.Now.ToString("yy/MM/dd|HH:mm:ss");

            return(string.Format("<color={1}>[{4}|{2}]</color><color={0}>{3}</color>", color, ccolor, channel.ToString(), message, time));
        }