示例#1
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value == null)
            {
                return(string.Empty);
            }

            LogState state = (LogState)value;

            return(state == LogState.None ? string.Empty : state.ToString());
        }
示例#2
0
        public void WriteLog(LogType logtype, string logmsg, LogState logstate)
        {
            sys_log log = new sys_log();

            log.id        = IdWorkerHelper.NewId();
            log.operation = UserCookie.AccountName;
            log.logtime   = DateTime.Now;
            log.logtype   = logtype.ToString();
            log.logmsg    = logmsg;
            log.loglevel  = logstate.ToString();
            log.logip     = "127.0.0.1"; //TODO
            Sqldb.Insertable(log).ExecuteCommand();
        }
示例#3
0
        public void WriteLog(LogType logtype, string logmsg, LogState logstate)
        {
            sys_log log = new sys_log();

            log.id        = IdWorkerHelper.NewId();
            log.operation = UserCookie.AccountName;
            log.logtime   = DateTime.Now;
            log.logtype   = logtype.ToString();
            log.logmsg    = logmsg;
            log.loglevel  = logstate.ToString();
            log.logip     = UserCookie.IP;
            _syslogRepository.Insert(log);
        }
示例#4
0
 /// <summary>
 /// Запись в лог-файл url с определенным статусом.
 /// </summary>
 public static void Push(string url, LogState state)
 {
     locker.EnterWriteLock();
     try
     {
         using (StreamWriter sw = new StreamWriter(logFilePath, true))
         {
             sw.WriteLine(url + logSeparator + state.ToString() + logSeparator + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year);
             sw.Close();
         }
     }
     finally
     {
         locker.ExitWriteLock();
     }
 }
示例#5
0
        public static string LogStateStr(bool withSqureBrackets, LogState state)
        {
            switch (state)
            {
            case LogState.None:
                return(string.Empty);

            default:
                if (withSqureBrackets)
                {
                    return($"[{state}]");
                }
                else
                {
                    return(state.ToString());
                }
            }
        }
示例#6
0
        public static void WriteLine(LogState pLogLevel, string pFormat, params object[] pArgs)
        {
            //  if (LogLogLevel > (byte)pLogLevel) return;
            string header = "[" + DateTime.Now.ToShortTimeString() + "] (" + pLogLevel + ") ";
            string buffer = string.Format(pFormat, pArgs);

            Locker.WaitOne();
            try
            {
                Console.ForegroundColor = GetColor(pLogLevel);

                if (((LogState)Enum.Parse(typeof(LogState), pLogLevel.ToString())).ToString() != "None")
                {
                    Console.Write(header);
                }

                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(buffer);
                if (String.IsNullOrEmpty(LogFile))
                {
                    return;
                }

                StreamWriter sw = File.AppendText(LogFile);
                try
                {
                    sw.WriteLine(header + buffer);
                }
                finally
                {
                    sw.Close();
                }
            }
            finally
            {
                Locker.ReleaseMutex();
            }
        }
示例#7
0
文件: Logger.cs 项目: arkanoid1/Temu
        public static void WriteLine(LogState pLogLevel, string pFormat, params object[] pArgs)
        {
            //  if (LogLogLevel > (byte)pLogLevel) return;
            string header = "[" + DateTime.Now.ToShortTimeString() + "] (" + pLogLevel + ") ";
            string buffer = string.Format(pFormat, pArgs);

            Locker.WaitOne();
            try
            {
                Console.ForegroundColor = GetColor(pLogLevel);

                if ( ((LogState)Enum.Parse(typeof(LogState), pLogLevel.ToString())).ToString() != "None" )
                {
                    Console.Write(header);
                }

                Console.ForegroundColor = ConsoleColor.Gray;
                Console.WriteLine(buffer);
                if (String.IsNullOrEmpty(LogFile))
                {
                    return;
                }

                StreamWriter sw = File.AppendText(LogFile);
                try
                {
                    sw.WriteLine(header + buffer);
                }
                finally
                {
                    sw.Close();
                }
            }
            finally
            {
                Locker.ReleaseMutex();
            }
        }
        private void Output(LogState state, string format, params object[] args)
        {
            DateTime now = DateTime.Now;
            string message = args.Length == 0 ? format : string.Format(format, args);
            string output = string.Format("[{0}], [{1}] : {2}",
                now.ToString(), state.ToString(), message);

            Console.ForegroundColor = getForegroundColor(state);

            Console.WriteLine(output);

            Console.ResetColor();
        }
示例#9
0
        private void Output(LogState state, string format, params object[] args)
        {
            lock (LockObject)
            {
                DateTime now = DateTime.Now;

                string message = args.Length == 0 ? format : string.Format(format, args);

                string output = string.Format("[{0}], [{1}] : {2}", now.ToString(), state.ToString(), message);

                WriteLog(output);
            }
        }
示例#10
0
 public string GetLogStateString(LogState state)
 {
     return(state.ToString());
 }