//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── public void Push(Log_Method log_Method) { Log_RecordCallstack log_RecordCallstack = new Log_CallstackRecordImpl(); log_RecordCallstack.Log_Method = log_Method; this.stack.Push(log_RecordCallstack); }
public void Push(Log_Method log_Method, string sStatementComment) { Log_RecordCallstack log_RecordCallstack = new Log_CallstackRecordImpl(); log_RecordCallstack.Log_Method = log_Method; log_RecordCallstack.Comment_Statement = sStatementComment; this.stack.Push(log_RecordCallstack); }
//──────────────────────────────────────── /// <summary> /// コンストラクター。 /// </summary> public Log_ReportsImpl(Log_Method log_Method_CreationMe) { this.bDebugEnable = true; this.bNotInfiniteLoop = true; this.list_Record = new List <Log_RecordReports>(); this.log_Callstack = new Log_CallstackImpl(); this.bSuccessful = true; this.log_Method_CreationMe = log_Method_CreationMe; this.comment_EventCreationMe = ""; }
//──────────────────────────────────────── static public void WriteErrorLog( Log_Method log_Method, MemoryApplication owner_MemoryApplication, Log_Reports log_Reports ) { // エラーログ出力。 owner_MemoryApplication.MemoryLogwriter.WriteErrorLog( owner_MemoryApplication, log_Reports, log_Method.Fullname); //Info_Functions.Name_Library + ":" + sClassName + sMethodNameWithSharp); }
//──────────────────────────────────────── /// <summary> /// コンストラクター。 /// </summary> public Log_ReportsImpl(Log_Method log_Method_CreationMe) { this.bDebugEnable = true; this.bNotInfiniteLoop = true; this.list_Record = new List<Log_RecordReports>(); this.log_Callstack = new Log_CallstackImpl(); this.bSuccessful = true; this.log_Method_CreationMe = log_Method_CreationMe; this.comment_EventCreationMe = ""; }
//──────────────────────────────────────── public static void WriteErrorLog( Log_Method log_Method, MemoryApplication owner_MemoryApplication, Log_Reports log_Reports ) { // エラーログ出力。 owner_MemoryApplication.MemoryLogwriter.WriteErrorLog( owner_MemoryApplication, log_Reports, log_Method.Fullname); //Info_Functions.Name_Library + ":" + sClassName + sMethodNameWithSharp); }
//──────────────────────────────────────── #endregion #region 判定 //──────────────────────────────────────── public bool Equals(Log_Method log_Method) { bool bEquals; if ( log_Method.Name_Library == this.Name_Library && log_Method.Name_Class == this.Name_Class && log_Method.IsStatic == this.IsStatic && log_Method.Name_Method == this.Name_Method ) { bEquals = true; } else { bEquals = false; } return(bEquals); }
/// <summary> /// このオブジェクトの生存の終了時。 /// </summary> public void EndLogging(Log_Method log_Method) { if (!this.Successful) { // エラー goto gt_Error_NotSuccessful; } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_NotSuccessful: //必ず実行。 { StringBuilder sb = new StringBuilder(); sb.Append("▲エラー!(L01 EndLogging)"); string strMessage = this.ToText(); // \n を、実際に改行する命令に変換。 strMessage = strMessage.Replace("\\n", System.Environment.NewLine); //一定数を超えた文字列は削ります。(ダイアログボックスが表示できなくなるので) if (1000 < strMessage.Length) { strMessage = strMessage.Substring(0, 999); } MessageBox.Show(strMessage, sb.ToString()); } //──────────────────────────────────────── #endregion // // gt_EndMethod: ; }
//──────────────────────────────────────── public void Push(Log_Method log_Method) { Log_RecordCallstack log_RecordCallstack = new Log_CallstackRecordImpl(); log_RecordCallstack.Log_Method = log_Method; this.stack.Push(log_RecordCallstack); }
//──────────────────────────────────────── /// <summary> /// コンストラクター。 /// </summary> public Log_StopwatchImpl(Log_Method owner_Log_Method) { this.owner_Log_Method = owner_Log_Method; this.message = ""; }
//──────────────────────────────────────── static public bool TryParse( object data, out string s_Out, string debugConfigStack_Table, string debugConfigStack_Field, Log_Method log_Method, Log_Reports log_Reports) { bool isResult; if (data is StringCellImpl) { s_Out = ((StringCellImpl)data).GetString(); isResult = true; } else if (data is DBNull) { // // 空欄は空文字列に。 s_Out = ""; isResult = true; } else if (null == data) { // // エラー goto gt_Error_Null; } else if (!(data is Cell)) { // // エラー goto gt_Error_NotCellData; } else { // // エラー goto gt_Error_AnotherType; } // 正常 goto gt_EndMethod; // // エラー。 //──────────────────────────────────────── gt_Error_Null: s_Out = "";//ゴミ値 isResult = false; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー241!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("指定の引数dataに、StringCellData型の値を指定してください。空っぽ(null)でした。"); s.Append(Environment.NewLine); s.Append("debugHintName=["); s.Append(debugConfigStack_Table); s.Append("."); s.Append(debugConfigStack_Field); s.Append("]"); s.Append(Environment.NewLine); s.Append("debugRunningHintName=["); s.Append(log_Method.Fullname); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_NotCellData: s_Out = "";//ゴミ値 isResult = false; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー243!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append(" 指定の引数dataに、CellData型の値を指定してください。"); s.Append(Environment.NewLine); s.Append(" 別の型[" + data.GetType().Name + "でした。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("debugHintName=["); s.Append(debugConfigStack_Table); s.Append("."); s.Append(debugConfigStack_Field); s.Append("]"); s.Append(Environment.NewLine); s.Append("debugRunningHintName=["); s.Append(log_Method.Fullname); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_AnotherType: s_Out = "";//ゴミ値 isResult = false; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー244!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("指定の引数の値["); s.Append(((Cell)data).Text); s.Append("]は、StringCellData型ではありませんでした。"); s.Append(Environment.NewLine); s.Append("debugHintName=["); s.Append(debugConfigStack_Table); s.Append("."); s.Append(debugConfigStack_Field); s.Append("]"); s.Append(Environment.NewLine); s.Append("debugRunningHintName=["); s.Append(log_Method.Fullname); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── // // gt_EndMethod: return(isResult); }
//──────────────────────────────────────── public void Pop(Log_Method log_Method) { Log_RecordCallstack err_Log_RecordCallstack; if (0 < this.stack.Count) { Log_RecordCallstack log_RecordCallstack = this.stack.Pop(); if (!log_RecordCallstack.Log_Method.Equals(log_Method)) { // エラー err_Log_RecordCallstack = log_RecordCallstack; goto gt_Error_MissmatchPop; } } else { // エラー goto gt_Error_EmptyPop; } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_MissmatchPop: { Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("最後にPushしたものに一致しないものをPopしました。"); s.Newline(); s.Append("今回Popした問題場所 : 今回Popしたもの"); s.Newline(); s.Append("定義SLibraryName [" + log_Method.Name_Library + "] : [" + err_Log_RecordCallstack.Log_Method.Name_Library + "]"); s.Newline(); s.Append("呼出SClassName [" + log_Method.Name_Class + "] : [" + err_Log_RecordCallstack.Log_Method.Name_Class + "]"); s.Newline(); s.Append("BStatic [" + log_Method.IsStatic + "] : [" + err_Log_RecordCallstack.Log_Method.IsStatic + "]"); s.Newline(); s.Append("SMethodName [" + log_Method.Name_Method + "] : [" + err_Log_RecordCallstack.Log_Method.Name_Method + "]"); s.Newline(); s.Append("もしかして?"); s.Newline(); s.Append(" ・EndMethod()が飛ばされた? 関数の途中でreturnやExceptionで抜けた場合や、EndMethodの記述漏れ?"); s.Newline(); //throw new Exception(s.ToString()); } goto gt_EndMethod; gt_Error_EmptyPop: { Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("PushしたものがないのにPopしました。"); s.Newline(); s.Append("今回Popした問題場所"); s.Newline(); s.Append("定義SLibraryName [" + log_Method.Name_Library + "]"); s.Newline(); s.Append("呼出SClassName [" + log_Method.Name_Class + "]"); s.Newline(); s.Append("BStatic [" + log_Method.IsStatic + "]"); s.Newline(); s.Append("SMethodName [" + log_Method.Name_Method + "]"); s.Newline(); throw new Exception(s.ToString()); } //goto gt_EndMethod; //──────────────────────────────────────── #endregion // // gt_EndMethod: ; }
//──────────────────────────────────────── /// <summary> /// 警告タイトル。 /// </summary> /// <param name="symbolError">エラー記号</param> /// <param name="log_Method"></param> public void SetTitle(string symbolError, Log_Method log_Method) { this.ErrorSymbol = symbolError; this.fullnameMethod = log_Method.Fullname; }
/// <summary> /// このオブジェクトの生存の終了時。 /// </summary> public void EndLogging(Log_Method log_Method) { if (!this.Successful) { // エラー goto gt_Error_NotSuccessful; } goto gt_EndMethod; // // #region 異常系 //──────────────────────────────────────── gt_Error_NotSuccessful: //必ず実行。 { StringBuilder sb = new StringBuilder(); sb.Append("▲エラー!(L01 EndLogging)"); string strMessage = this.ToText(); // \n を、実際に改行する命令に変換。 strMessage = strMessage.Replace("\\n", System.Environment.NewLine); //一定数を超えた文字列は削ります。(ダイアログボックスが表示できなくなるので) if (1000<strMessage.Length) { strMessage = strMessage.Substring(0, 999); } MessageBox.Show(strMessage, sb.ToString()); } //──────────────────────────────────────── #endregion // // gt_EndMethod: ; }
//──────────────────────────────────────── #endregion #region アクション //──────────────────────────────────────── /// <summary> /// 警告タイトル。 /// </summary> /// <param name="symbolError">エラー記号</param> /// <param name="log_Method"></param> public void SetTitle(string symbolError, Log_Method log_Method) { this.ErrorSymbol = symbolError; this.fullnameMethod = log_Method.Fullname; }
//──────────────────────────────────────── public static bool TryParse( object data, out string s_Out, string sDebugConfigStack_Table, string sDebugConfigStack_Field, Log_Method log_Method, Log_Reports log_Reports) { bool bResult; if (data is String_HumaninputImpl) { s_Out = ((String_HumaninputImpl)data).GetString(); bResult = true; } else if (data is DBNull) { // // 空欄は空文字列に。 s_Out = ""; bResult = true; } else if (null == data) { // // エラー goto gt_Error_Null; } else if (!(data is Value_Humaninput)) { // // エラー goto gt_Error_NotCellData; } else { // // エラー goto gt_Error_AnotherType; } // 正常 goto gt_EndMethod; // // エラー。 //──────────────────────────────────────── gt_Error_Null: s_Out = "";//ゴミ値 bResult = false; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー241!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("指定の引数dataに、StringCellData型の値を指定してください。空っぽ(null)でした。"); s.Append(Environment.NewLine); s.Append("debugHintName=["); s.Append(sDebugConfigStack_Table); s.Append("."); s.Append(sDebugConfigStack_Field); s.Append("]"); s.Append(Environment.NewLine); s.Append("debugRunningHintName=["); s.Append(log_Method.Fullname); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_NotCellData: s_Out = "";//ゴミ値 bResult = false; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー243!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append(" 指定の引数dataに、CellData型の値を指定してください。"); s.Append(Environment.NewLine); s.Append(" 別の型[" + data.GetType().Name + "でした。"); s.Append(Environment.NewLine); s.Append(Environment.NewLine); s.Append("debugHintName=["); s.Append(sDebugConfigStack_Table); s.Append("."); s.Append(sDebugConfigStack_Field); s.Append("]"); s.Append(Environment.NewLine); s.Append("debugRunningHintName=["); s.Append(log_Method.Fullname); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── gt_Error_AnotherType: s_Out = "";//ゴミ値 bResult = false; if (log_Reports.CanCreateReport) { Log_RecordReports r = log_Reports.BeginCreateReport(EnumReport.Error); r.SetTitle("▲エラー244!", log_Method); Log_TextIndented s = new Log_TextIndentedImpl(); s.Append("指定の引数の値["); s.Append(((Value_Humaninput)data).Text); s.Append("]は、StringCellData型ではありませんでした。"); s.Append(Environment.NewLine); s.Append("debugHintName=["); s.Append(sDebugConfigStack_Table); s.Append("."); s.Append(sDebugConfigStack_Field); s.Append("]"); s.Append(Environment.NewLine); s.Append("debugRunningHintName=["); s.Append(log_Method.Fullname); s.Append("]"); r.Message = s.ToString(); log_Reports.EndCreateReport(); } goto gt_EndMethod; //──────────────────────────────────────── // // gt_EndMethod: return bResult; }
//──────────────────────────────────────── public bool Equals(Log_Method log_Method) { bool bEquals; if( log_Method.Name_Library == this.Name_Library && log_Method.Name_Class == this.Name_Class && log_Method.IsStatic == this.IsStatic && log_Method.Name_Method == this.Name_Method ) { bEquals = true; } else { bEquals = false; } return bEquals; }