예제 #1
0
        public bool Log(LoggingArgument arg)
        {
            if (arg == null)
            {
                return(false);
            }

            try
            {
                string logFilePath = FilePath ?? "C:\\Example.txt";

                using (FileStream fs = File.Open(logFilePath, FileMode.Append, FileAccess.Write))
                {
                    using (TextWriter tw = new StreamWriter(fs))
                    {
                        tw.Write(arg.ToString());
                    }
                }
            }
            catch
            {
                return(false);
            }

            return(true);
        }
        public bool Log(LoggingArgument arg)
        {
            if (arg == null)
            {
                return(false);
            }

            ConsoleColor oldForeground = Console.ForegroundColor;

            switch (arg.LogType)
            {
            case LoggingType.Invoke:
                Console.ForegroundColor = InvokeLogColor;
                break;

            case LoggingType.Result:
                Console.ForegroundColor = ResultLogColor;
                break;

            case LoggingType.Error:
                Console.ForegroundColor = ErrorLogColor;
                break;

            case LoggingType.Warning:
                Console.ForegroundColor = WarningLogColor;
                break;

            case LoggingType.Information:
                Console.ForegroundColor = InformationLogColor;
                break;

            default:
                break;
            }

            Console.WriteLine(arg.ToString());

            Console.ForegroundColor = oldForeground;

            return(true);
        }
예제 #3
0
 public bool Log(LoggingArgument arg)
 {
     log.Debug(arg.ToString());
     return(true);
 }