public Log(string message, Exception ex, LogInfoType logType) { this.Message = message; this.AdditionalInformation = ex.Message; this.LogType = logType; this.StackTrace = ex.StackTrace; }
public void Write(LogInfoType logType, string log) { var now = DateTime.Now; var date = now.ToShortDateString(); var time = now.ToLongTimeString(); var ms = now.Millisecond.ToString().PadLeft(3, '0'); switch (logType) { case LogInfoType.ReceiveCommandFromEngine: log = $"{date} {time}'{ms} > {log}"; break; case LogInfoType.SendCommandToEngine: log = $"{date} {time}'{ms} < {log}"; break; case LogInfoType.SystemError: log = $"{date} {time}'{ms} Error : {log}"; break; case LogInfoType.UsiServer: log = $"{date} {time}'{ms} USI Server : {log}"; break; } sw.WriteLine(log); sw.Flush(); }
/// <summary> /// ログ出力用に整形する。 /// </summary> /// <param name="logType"></param> /// <param name="log"></param> /// <returns></returns> public static string Format(LogInfoType logType, string log, int pipe_id = -1) { var now = DateTime.Now; var date = now.ToShortDateString(); var time = now.ToLongTimeString(); var ms = now.Millisecond.ToString().PadLeft(3, '0'); switch (logType) { case LogInfoType.ReceiveCommandFromEngine: log = $"{date} {time}'{ms} [{pipe_id}>] {log}"; break; case LogInfoType.SendCommandToEngine: log = $"{date} {time}'{ms} [{pipe_id}<] {log}"; break; case LogInfoType.SystemError: log = $"{date} {time}'{ms} Error : {log}"; break; case LogInfoType.UsiParseError: log = $"{date} {time}'{ms} USI Parse Error : {log}"; break; case LogInfoType.UsiServer: log = $"{date} {time}'{ms} USI Server : {log}"; break; } return(log); }
public void Write(LogInfoType logType, string log, int pipe_id) { var f_log = LogHelpper.Format(logType, log, pipe_id); lock (lock_object) { sw.WriteLine(f_log); sw.Flush(); } }
private void log(LogInfoType type, string str, LogCategory category = LogCategory.I, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0) { if (OutputLog != null) { OutputLog(type, str, category, memberName, filePath, lineNumber); } }
public static void Write(LogInfoType logType, string message, int pipe_id = -1) { // logがアタッチされていないときは、なるべく小さなオーバーヘッドで済むように、 // Format()はここでは呼び出さない。 if (log1 != null) { log1.Write(logType, message, pipe_id); } if (log2 != null) { log2.Write(logType, message, pipe_id); } }
private static void BeginTraceError(LogInfoType logInfoType, string logInfo) { if (string.IsNullOrEmpty(logInfo)) { MessageBox.Show("参数非法!"); } lock (mutex_Logger) { switch (logOutType) { case LogOutType.OT_File: { //检测日志日期 StrategyLog(); System.Diagnostics.Trace.WriteLine(logInfo); if (fileFlushType == FileFlushType.RightNow) { System.Diagnostics.Trace.Close(); } break; } case LogOutType.OT_Net: { break; } case LogOutType.OT_Both: { //检测日志日期 StrategyLog(); System.Diagnostics.Trace.WriteLine(logInfo); if (fileFlushType == FileFlushType.RightNow) { System.Diagnostics.Trace.Close(); } break; } } } }
public void Write(LogInfoType logType, string log, int pipe_id) { var f_log = LogHelpper.Format(logType, log, pipe_id); lock (lock_object) { LogList.Enqueue(f_log); // 上限行数を超えていたら末尾のものを取り除く。 if (LogList.Count > MaxLine) { LogList.Dequeue(); } } // イベントハンドラが設定されていればcallbackしたいが、lock解除してからでないとdead lockになる。 ListAdded?.Invoke(f_log); }
/// <summary> /// 日志打印。 /// </summary> /// <param name="str"></param> public static void StaticOutputLog(LogInfoType type, string str, string modeName, LogCategory category = LogCategory.I, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0) { if (type < DataController.LogOutputLevel) { return; } string outStr = string.Format("{0}", str); //Console.WriteLine(outStr); FrmMainController.add_log_info(type, outStr, modeName, category, filePath, memberName, lineNumber); Logger.Trace(type, outStr, modeName, category, memberName, filePath, lineNumber); outStr = null; }
public void Write(LogInfoType logType, string log, int pipe_id) { var f_log = LogHelpper.Format(logType, log, pipe_id); List <string> c = null; lock (lock_object) { LogList.Add(f_log); if (ListAdded != null) { c = new List <string>(LogList); // clone } } // イベントハンドラが設定されていればcallbackしたいが、lock解除してからでないとdead lockになる。 // かと言って、LogListはmutableだし…。仕方ないのでClone()しといてそれ渡す。オーバーヘッドすごすぎ…。 // まあ、ロギングしていない時は、オーバーヘッドなしと考えられるので、これはこれでいいや…。 if (ListAdded != null) { ListAdded(c); } }
public void OpenLogNetworking() { logInfoType = LogInfoType.Networking; Networking(); gameObject.SetActive(true); }
public void Write(LogInfoType logType, string log, int pipe_id = -1) { }
public static void Write(LogInfoType logType, string message) { log.Write(logType, message); }
public void Write(LogInfoType logType, string log) { }
public static void Trace(LogInfoType logInfoType, string logInfo, string moduleName, LogCategory cat, [CallerMemberName] string memberName = "", [CallerFilePath] string filePath = "", [CallerLineNumber] int lineNumber = 0) { //if (logInfoType < LogInfoType.DEBG) //{ // return; //} if (string.IsNullOrEmpty(logInfo) || string.IsNullOrEmpty(moduleName)) { return; } string tmp = ""; if (logInfoType == LogInfoType.DEBG) { tmp = string.Format(LOG_DEBG, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"), ++gLogIndex, Path.GetFileName(filePath), lineNumber); } else if (logInfoType == LogInfoType.INFO) { tmp = string.Format(LOG_INFO, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"), ++gLogIndex, Path.GetFileName(filePath), lineNumber); } else if (logInfoType == LogInfoType.WARN) { tmp = string.Format(LOG_WARN, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"), ++gLogIndex, Path.GetFileName(filePath), lineNumber); } else if (logInfoType == LogInfoType.EROR) { tmp = string.Format(LOG_EROR, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"), ++gLogIndex, Path.GetFileName(filePath), lineNumber); } else { tmp = string.Format(LOG_INFO, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss fff"), ++gLogIndex, Path.GetFileName(filePath), lineNumber); } /* * 2018-07-16,区分Log的开始 */ if (logInfo.Contains("今天是个好日子")) { tmp = "\r\n\r\n" + tmp; //logInfo = string.Format("{0}({1})", logInfo, FrmMainController.GSvnVersionString); } if (cat == LogCategory.R) { tmp += string.Format("【{0},R】{1}", moduleName, logInfo); } else if (cat == LogCategory.S) { tmp += string.Format("【{0},S】{1}", moduleName, logInfo); } else { tmp += string.Format("【{0},I】{1}", moduleName, logInfo); } lock (mutex_Logger) { gQueueLogger.Enqueue(tmp); } //new AsyncLogString(BeginTraceError).BeginInvoke(logInfoType, tmp, null, null); }
public HttpRequestLogInfoModel(LogInfoType requestLogType) { LogType = requestLogType; SetRequestLogTypeMsg(); }