Exemple #1
0
        public static void Log(ELogTypes logType,string format)
        {
            
            ConsoleColor c;
            switch(logType)
            {
                case ELogTypes.Debug:
                    c = ConsoleColor.Green;
                    break;
                case ELogTypes.Error:
                    c = ConsoleColor.Red;
                    break;
                case ELogTypes.Info:
                    c = ConsoleColor.White;
                    break;
                default:
                    c = Console.ForegroundColor;
                    break;
            }

            Console.ForegroundColor = c;
            Console.Write(string.Format("<{0}>", logType.ToString()).PadRight(7,' '));
            Console.ResetColor();
            Console.WriteLine(" {0}",format);

        }
        string AddLog(string msg, string filepath, string name, int line, ELogTypes type)
        {
            var fn      = Path.GetFileName(name);
            var fullmsg = $"Date: {DateTime.UtcNow.ToString("dd/MM/yy HH:mm:ss")} {fn}:{name} Line:{line} LogType: {type.ToString()} Msg: {msg}";

            if (EnDebug)
            {
                Console.WriteLine(fullmsg);
            }
            return(fullmsg);
        }
        string AddLog(string msg, string filepath, string name, int line, ELogTypes type)
        {
            var fn      = Path.GetFileName(name);
            var fullmsg = $"Date: {DateTime.UtcNow.ToString("dd/MM/yy HH:mm:ss")} {fn}:{name} Line:{line} LogType: {type.ToString()} Msg: {msg} \n";

            File.AppendAllText(GetLogFileName, fullmsg);
            if (EnDebug && Handy.IsInteractive())
            {
                Console.WriteLine(fullmsg);
            }
            return(fullmsg);
        }