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()); }
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(); }
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); }
/// <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(); } }
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()); } } }
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(); } }
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(); }
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); } }
public string GetLogStateString(LogState state) { return(state.ToString()); }