public void Notify(string i_Msg, eLogType i_LogType, string i_LogData) { MyDiveEntities MyDiveDB = null; try { DateTime d = DateTime.Now.Date; MyDiveDB = new MyDiveEntities(); MyDiveDB.stp_InsertLog( (int)i_LogType, i_Msg, DateTime.Now.Date, i_LogData); } catch (Exception ex) { throw ex; } finally { if (MyDiveDB != null) { MyDiveDB.Dispose(); } } }
/// <summary> /// Crea e scrive su un file di testo il messaggio passato come parametro e del tipo specificato. /// Il file se creato presenta come nome quello presente nella FileNameTemplate oppure quello generato dalla FileNameCreator. /// </summary> public static void Write(eLogType MessageType, string Message) { if (Message is null) { throw new ArgumentNullException("Message"); } try { // // Creo il mio oggetto da scrivere // LogData obj = new LogData { Date = DateTime.Now, Type = MessageType, Message = Message.Trim(), Source = "", StackTrace = "", TargetSite = "" }; QueueAndWrite(obj); } catch (Exception ex) { Console.WriteLine("Logger.Write -> ", ex.Message); } }
/// <summary> /// Crea e scrive su un file di testo le informazioni dell'eccezione passata. /// Il file se creato presenta come nome quello presente nella FileNameTemplate oppure quello generato dalla FileNameCreator. /// </summary> public static void Write <T>(eLogType MessageType, T Ex, bool Verbose) where T : Exception { if (Ex is null) { throw new ArgumentNullException("Ex"); } try { string strMessage = CreateObjectMessage(Ex, Verbose); // // Creo il mio oggetto da scrivere // LogData obj = new LogData { Date = DateTime.Now, Type = MessageType, Message = strMessage, Source = Ex.Source, StackTrace = Ex.StackTrace, TargetSite = Ex.TargetSite?.ToString() }; QueueAndWrite(obj); } catch (Exception ex) { Console.WriteLine("Logger.Write -> ", ex.Message); } }
public void SetType(eLogType pType) { if (pType != eLogType.NONE) { _type = pType; } }
public void Log(eLogType i_LogType, AgentInstance i_AgentInstance, string i_Info, string i_Elapsed) { string machineName = i_AgentInstance.ComputerName; string IP = i_AgentInstance.IP; Log(i_LogType, machineName, IP, string.Empty, i_Info, i_Elapsed); }
/// <summary> /// Description : Convert a unity logtype into a Console service log type /// </summary> /// <param name="pType"></param> /// <returns></returns> public static eLogType ConvertLogType(LogType pType) { eLogType lResult = eLogType.NONE; switch (pType) { case LogType.Log: lResult = eLogType.LOG; break; case LogType.Warning: lResult = eLogType.WARNING; break; case LogType.Assert: lResult = eLogType.ASSERT; break; case LogType.Error: lResult = eLogType.ERROR; break; case LogType.Exception: lResult = eLogType.EXCEPTION; break; } return(lResult); }
private static void TryUpdateLog(eLogType type, LogMessage message) { if (isGuiLogInitialzed) { UpdateLogCall(type, message.Category, message.TimeStamp, message.Description); } }
public void PrintLog(eLogType logType, string str) { if ((avtiveLogType & logType) != 0) { Debug.Log(string.Format("<color=#{0}> {1} </color>", logDict[logType], str)); } }
public static void LogWarning(eLogType eType, string str /*, params object[] args*/) { if (!CheckLog(eLoglevel.LL_WARNING, eType)) { return; } Debug.LogWarning("(‧_‧?) " + str); }
public static void LogError(eLogType eType, string str /*, params object[] args*/) { if (!CheckLog(eLoglevel.LL_ERROR, eType)) { return; } Debug.LogError("(¯ □ ¯) " + str); }
public static void Log(eLogType eType, string str /*, params object[] args*/) { if (!CheckLog(eLoglevel.LL_NORMAL, eType)) { return; } Debug.Log(":-) " + str); }
public void Log(eLogType i_LogType, string i_MachineName, string i_IP, string i_ServiceName, string i_Info,string i_Elapsed) { Object obj = new object(); lock (obj) { string time = DateTime.Now.ToString(); m_DataGridView.Rows.Add(new string[] { DateTime.Now.ToString(), Enum.GetName(typeof(eLogType), i_LogType), i_MachineName, i_IP, i_ServiceName, i_Info, i_Elapsed }); } }
public void Log(eLogType i_LogType, string i_MachineName, string i_IP, string i_ServiceName, string i_Info, string i_Elapsed) { Object obj = new object(); lock (obj) { string time = DateTime.Now.ToString(); m_DataGridView.Rows.Add(new string[] { DateTime.Now.ToString(), Enum.GetName(typeof(eLogType), i_LogType), i_MachineName, i_IP, i_ServiceName, i_Info, i_Elapsed }); } }
/// <summary> /// Add /// </summary> /// <param name="str"></param> /// <param name="type"></param> public void Add(string str, eLogType type) { Monitor.Enter(@lock); try { if (m_config.UseConsole) { ConsoleColor old = Console.ForegroundColor; Console.ForegroundColor = m_config.ConsoleColors[(int)type]; Console.WriteLine($@"[{DateTime.Now.ToString()}] {str}"); Console.ForegroundColor = old; } if (m_config.UseFile) { if (!m_config.FilePath.IsExistsPath()) { Directory.CreateDirectory(m_config.FilePath); } var name = m_config.FilePath + DateTime.Now.ToString("yyyy-MM-dd"); var num = 0; while (FileHelper.GetLength(name + (num == 0 ? "" : $"-{num}") + ".log") > 100*1024*1024)//100k { num++; } name = name+( num == 0 ? "" : $"-{num}") +".log"; File.AppendAllText(name, $@"[{type.ToString()}] {DateTime.Now.ToString()} {str} "); } if(m_config.UseLogView) { var a = this.m_config.LogView; a.Select(a.TextLength, 1); //WTF!!!!!!! a.SelectionColor = m_config.LogViewColors[(int)type]; a.IsNewAdd = true; a.AppendLine($@"[{DateTime.Now.ToString()}] {str}"); } } catch (Exception e) { if (this.m_config.UseMessageBox) { WinForm.Notice(e.ToString()); } } finally { Monitor.Exit(@lock); } }
public void WriteLog(string message, eLogType logType) { if (_logConfig == null) { throw new LogException("Current log has not been initialized."); } var toWrite = $" {DateTime.Now: dd/MM/yyy HH:mm} - {message}"; Console.ForegroundColor = GetMessageColor(logType); Console.WriteLine(toWrite); }
static public void AddLog(string sContent, eLogType LogType) { if (string.IsNullOrEmpty(sContent)) return; t_Log mLog = new t_Log(); mLog.ID = "Log:" + DateTime.Now.Ticks; mLog.LogTime = DateTime.Now; mLog.sContent = sContent; mLog.sType = LogType.ToString(); bLog.Add(mLog); }
public static bool CheckLog(eLoglevel elevel, eLogType eType) { if (DebugLogger.eLogLevel == eLoglevel.LL_CLOSE) { return(false); } if ((DebugLogger.eLogLevel & elevel) == elevel) { if ((DebugLogger.eLogType & eType) == eType) { return(true); } } return(false); }
/// <summary> /// Method for logging custom message /// </summary> /// <param name="logContext"></param> /// <param name="logType"></param> /// <param name="context"></param> /// <param name="message"></param> public static void Log(eLogContext logContext, eLogType logType, HttpContext context, string message) { switch (logContext) { case eLogContext.Application: //TODO: log application type event... break; case eLogContext.Session: //TODO: log session type event... break; default: throw new NotImplementedException("eLogContext '" + logContext.ToString() + "' is not implemented!"); } }
/// <summary> /// Update Log function to be passed as delegate /// </summary> /// <param name="type">Log type</param> /// <param name="category">Log category</param> /// <param name="timestamp">Log timestamp</param> /// <param name="message">Log message</param> public void UpdateLog(eLogType type, eLogCategory category, DateTime timestamp, string message) { UILogMessage logmessage = new UILogMessage(); logmessage.FontColor = DefineColor(category); logmessage.Message = DefineMessage(type, category, timestamp, message); logmessage.Type = type; Dispatcher.BeginInvoke(new ThreadStart(delegate { _logMessageList.Add(logmessage); if (AutoscrollCheckbox) { _guiLog.ScrollIntoView(_logMessageList.Last()); } })); }
static public void AddLog(string sContent, eLogType LogType) { if (string.IsNullOrEmpty(sContent)) { return; } t_Log mLog = new t_Log(); mLog.ID = "Log:" + DateTime.Now.Ticks; mLog.LogTime = DateTime.Now; mLog.sContent = sContent; mLog.sType = LogType.ToString(); bLog.Add(mLog); }
private ConsoleColor GetMessageColor(eLogType logType) { switch (logType) { case eLogType.Error: return(ERRORCOLOR); case eLogType.Info: return(INFOCOLOR); case eLogType.Warning: return(WARNINGCOLOR); default: return(INFOCOLOR); } }
/// <summary> /// Get string error type /// </summary> /// <param name="logType"></param> /// <returns></returns> private string GetMessageStringType(eLogType logType) { switch (logType) { case eLogType.Error: return(ERROR); case eLogType.Info: return(INFO); case eLogType.Warning: return(WARNING); default: return(INFO); } }
public void WriteLog(string message, eLogType logType) { if (_logConfigFile == null) { throw new LogException("Current log has not been initialized."); } try { var logToWrite = $"{this.GetMessageStringType(logType)} {DateTime.Now: dd/MM/yyy HH:mm} - {message}"; using (StreamWriter fileStream = this.GetLogFile()) { fileStream.WriteLine(logToWrite); } } catch (Exception ex) { throw new LogException("Log to file failed. See inner exception for detail.", ex); } }
public void Log(eLogType logType, string message) { switch (logType) { case eLogType.Debug: log.Debug(message); break; case eLogType.Warning: log.Warn(message); break; case eLogType.Error: log.Error(message); break; case eLogType.Info: default: log.Info(message); break; } }
public void WriteLog(string message, eLogType logType) { if (_logConfigDB == null) { throw new LogException("Current log has not been initialized."); } try { using (SqlConnection connection = this.GetConnection()) { SqlCommand command = this.BuildCommand(connection, message, (int)logType); command.Connection.Open(); command.ExecuteNonQuery(); } } catch (Exception ex) { throw new LogException("Log to database failed. See inner exception for detail.", ex); } }
void OnGUI() { GUI.contentColor = Color.red; GUI.Label(new Rect(0, 0, 150, 50), "FPS:" + m_FPS); //if (!canShow) return; if (canShow == false) { GUI.contentColor = Color.red; GUI.skin.button.alignment = TextAnchor.MiddleCenter; if (GUI.Button(new Rect(width * 0.5f, 0, 150, 50), "Console")) { canShow = true; } return; } GUI.backgroundColor = Color.black; ///关闭 GUI.contentColor = Color.red; GUI.backgroundColor = Color.red; GUI.skin.button.fontStyle = FontStyle.Bold; GUI.skin.button.alignment = TextAnchor.MiddleCenter; //GUI.skin.button.fontSize = 20; GUI.skin.button.wordWrap = true; if (GUI.Button(new Rect(width + 20, 0, 150, 80), "关闭")) { canShow = false; } ///清空 GUI.contentColor = Color.green; GUI.backgroundColor = Color.green; if (GUI.Button(new Rect(width + 20, height - 160, 150, 80), "清空")) { MessageList.Clear(); maxCount = 0; canShowInfo = false; ScrollbarColor = Color.green; return; } GUI.contentColor = Color.blue; GUI.backgroundColor = Color.blue; if (GUI.Button(new Rect(width + 20, height - 60, 150, 80), "全部")) { currType = eLogType.All; ScrollbarColor = Color.blue; } GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; if (GUI.Button(new Rect(width + 20, height + 20, 150, 80), "输出")) { ScrollbarColor = Color.white; currType = eLogType.Log; } GUI.contentColor = Color.red; GUI.backgroundColor = Color.red; if (GUI.Button(new Rect(width + 20, height + 100, 150, 80), "错误")) { ScrollbarColor = Color.red; currType = eLogType.Error; } GUI.contentColor = Color.yellow; GUI.backgroundColor = Color.yellow; if (GUI.Button(new Rect(width + 20, height + 180, 150, 80), "警告")) { ScrollbarColor = Color.yellow; currType = eLogType.Warning; } temp.Clear(); for (int i = 0; i < MessageList.Count; i++) { if (currType != eLogType.All) { if (currType == eLogType.Error) { if (MessageList[i].type != eLogType.Assert && MessageList[i].type != eLogType.Error && MessageList[i].type != eLogType.Exception) { continue; } } else if (currType != MessageList[i].type) { continue; } } temp.Add(MessageList[i]); } if (MessageList.Count > maxCount) { scrollPosition = new Vector2(0, temp.Count * offetHeight); } GUI.backgroundColor = ScrollbarColor; scrollPosition = GUI.BeginScrollView(new Rect(0, height, width + 20, height), scrollPosition, new Rect(0, 0, width, temp.Count * offetHeight)); GUI.backgroundColor = Color.black; GUI.skin.verticalScrollbar.stretchWidth = true; GUI.skin.verticalScrollbar.fixedWidth = 100; GUI.skin.verticalScrollbarThumb.fixedWidth = 100; for (int i = 0; i < temp.Count; i++) { GUI.contentColor = temp[i].color; GUI.skin.button.alignment = TextAnchor.MiddleLeft; GUI.skin.button.fontSize = 30; GUI.skin.button.wordWrap = false; if (GUI.Button(new Rect(0, i * offetHeight, width, offetHeight), temp[i].message)) { currIndex = i; canShowInfo = true; } } GUI.EndScrollView(); maxCount = MessageList.Count; if (canShowInfo) { if (currIndex > 0 && currIndex < temp.Count) { GUI.backgroundColor = ScrollbarColor; showScrollPosition = GUILayout.BeginScrollView(showScrollPosition, GUILayout.Width(width + 20), GUILayout.Height(height)); GUI.backgroundColor = Color.black; GUI.contentColor = Color.white; GUI.skin.button.wordWrap = true; GUILayout.Button(temp[currIndex].message); GUILayout.Button(temp[currIndex].stackTrace); GUILayout.EndScrollView(); } } }
public static void Critical(eLogType _type, String _msg) { LogInfo(eLogLevel.Critical, _type, _msg); }
public static void Critical(eLogType _type, String _format, params System.Object[] _args) { LogInfo(eLogLevel.Critical, _type, _format, _args); }
public static void LogInfo(eLogLevel _level, eLogType _type, String _format, params System.Object[] _args) { // 未开启的不显示 if (!s_instance.m_log_type_switch[(Int32)_type] && (Int32)eLogLevel.Warning > (Int32)_level) { return; } // 未达到等级的不显示 if (_level < s_instance.m_release_log_level) { return; } // 组装日志 s_instance.m_string_buider.Length = 0; #if !UNITY_EDITOR s_instance.m_string_buider.AppendFormat("[{0}][{1}]:\t", _level, _type); #else s_instance.m_string_buider.AppendFormat("<color=#{2}>[{0}][{1}]:\t", _level, _type, s_colors[(Int32)_level]); #endif s_instance.m_string_buider.AppendFormat(_format, _args); #if UNITY_EDITOR s_instance.m_string_buider.Append("</color>"); #endif //Instance._showLog( _level, _type, Instance.m_string_buider.ToString() ); switch (_level) { case eLogLevel.Verbose: case eLogLevel.Debug: case eLogLevel.Info: #if UNITY_EDITOR s_instance.m_logger.Log(LogType.Log, s_instance.m_string_buider.ToString()); #else s_instance.m_logger.Log(LogType.Log, WeiqiApp.PROJECT_NAME, s_instance.m_string_buider.ToString()); #endif break; case eLogLevel.Warning: #if UNITY_EDITOR s_instance.m_logger.Log(LogType.Warning, s_instance.m_string_buider.ToString()); #else s_instance.m_logger.Log(LogType.Warning, WeiqiApp.PROJECT_NAME, s_instance.m_string_buider.ToString()); #endif break; case eLogLevel.Error: case eLogLevel.Critical: #if UNITY_EDITOR s_instance.m_logger.Log(LogType.Error, s_instance.m_string_buider.ToString()); #else s_instance.m_logger.Log(LogType.Error, WeiqiApp.PROJECT_NAME, s_instance.m_string_buider.ToString()); #endif break; } }
public LogData(eLogLevel _level, eLogType _type, String _string) { m_log_level = _level; m_log_type = _type; m_log_string = _string; }
/// <summary> /// Main function to be called when logging to database is needed. /// </summary> /// <param name="sMsg">Message to be logged</param> /// <param name="_eltType">Type of log</param> public void log(string _sMsg, eLogType _eltType) { Tuple<string, string, DateTime> tupleTemp; switch (_eltType) { case eLogType.LOG_INFO: tupleTemp = new Tuple<string, string, DateTime>("Info", _sMsg, DateTime.Now); addItemToQueue(tupleTemp); break; case eLogType.LOG_ERROR: tupleTemp = new Tuple<string, string, DateTime>("Error", _sMsg, DateTime.Now); addItemToQueue(tupleTemp); break; case eLogType.LOG_DEBUG: tupleTemp = new Tuple<string, string, DateTime>("Debug", _sMsg, DateTime.Now); addItemToQueue(tupleTemp); break; } }
/// <summary> /// Private Log Singleton Constructor - in use /// </summary> /// <param name="type">Type of log to instantiate and start</param> private Log(eLogType type) { _type = type; _inputMessageQ = new Queue <LogMessage>(); Start(); }
public void WriteLog(string message, eLogType logType) { MessageLoged = message; }
/// <summary> /// Add /// </summary> /// <param name="str"></param> /// <param name="e"></param> /// <param name="type"></param> public void Add(string str, Exception e, eLogType type) => Add(str + "\n" + e.ToString(),type);
public void Log(eLogType i_LogType, AgentInstance i_AgentInstance, string i_Info,string i_Elapsed) { string machineName = i_AgentInstance.ComputerName; string IP = i_AgentInstance.IP; Log(i_LogType, machineName, IP, string.Empty, i_Info, i_Elapsed); }
/// <summary> /// Message to printable format /// </summary> /// <param name="message">Message to format</param> /// <param name="type">Type of log</param> /// <returns>Message as string</returns> private string DefineMessage(eLogType type, eLogCategory category, DateTime timestamp, string message) { return(String.Format("{0}\t{1}\t{3}", timestamp.ToString("HH:mm:ss:fff"), category, type, message)); }