示例#1
0
        public static bool EnableDebugOption(string type, bool mode)
        {
            DebugTypeEnum debugEnum = DebugTypeEnum.None;

            if (!DebugTypeEnum.TryParse(type, out debugEnum))
            {
                return(false);
            }

            if (mode)
            {
                if (!CurrentDebugTypeList.Contains(debugEnum))
                {
                    CurrentDebugTypeList.Add(debugEnum);
                }
            }
            else
            {
                if (CurrentDebugTypeList.Contains(debugEnum))
                {
                    CurrentDebugTypeList.Remove(debugEnum);
                }
            }

            return(true);
        }
        /// <summary>
        /// checks if type equals debug.
        /// </summary>
        /// <param name="inDebugType">the debug type to compare.</param>
        private static bool debugTypeEquals(DebugTypeEnum inDebugType)
        {
            // Written, 15.10.2018

            if (MoControlsSaveData.loadedSaveData != null)
            {
                if (MoControlsSaveData.loadedSaveData.debugMode == DebugTypeEnum.full)
                {
                    return(true);
                }
                if (MoControlsSaveData.loadedSaveData.debugMode == DebugTypeEnum.partial)
                {
                    if (inDebugType == DebugTypeEnum.none)
                    {
                        return(true);
                    }
                }
                if (MoControlsSaveData.loadedSaveData.debugMode == inDebugType)
                {
                    return(true);
                }
            }
            else
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// Prints a message to the console with the prefix of the mod name.
        /// </summary>
        /// <param name="inMessage"></param>
        internal static void print(string inMessage, DebugTypeEnum inDebugType)
        {
            // Written, 08.10.2018

            if (debugTypeEquals(inDebugType))
            {
                string _msg = String.Format("<i><color=grey>[{0}]</color> <b><color=green>>></color></b></i> {1}", instance.Name, inMessage);
                ModConsole.Print(_msg);
            }
        }
示例#4
0
        public void LogEvent(string text, DebugTypeEnum eventType)
        {
            if (!Logger.LoggerDebugMode)
            {
                return;
            }

            var sb = new StringBuilder();

            sb.Append("[").Append(DateTime.Now.ToString("yyyyMMddHHmmssfff")).Append("] ");
            sb.Append("[").Append(eventType.ToString()).Append("] ");
            sb.Append(text).AppendLine();
        }
示例#5
0
        public static void MsgDebug(string message, DebugTypeEnum type = DebugTypeEnum.None)
        {
            if (!LoggerDebugMode)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(message))
            {
                return;
            }

            if (!IsMessageValid(type))
            {
                return;
            }

            string typeModifier = type.ToString() + ": ";

            if (DebugWriteToLog)
            {
                MyLog.Default.WriteLineAndConsole(LogDefaultIdentifier + typeModifier + message);
            }
        }
示例#6
0
 public static bool IsMessageValid(DebugTypeEnum type)
 {
     return(CurrentDebugTypeList.Contains(type));
 }