Logging OCL in Turnkey
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
[[File:SysLoggingView.png|none|thumb|554x554px]] | [[File:SysLoggingView.png|none|thumb|554x554px]] | ||
public partial class SysLogging | |||
{ | |||
StringBuilder sb = new StringBuilder(100000); | |||
void Singleton_OnTraceLog(object sender, Eco.Logging.TraceEventArgs e) | |||
{ | |||
if (sb.Length > 5000000) | |||
sb.Clear(); | |||
sb.AppendLine(e.Message); | |||
} | |||
[UmlElement(Id = "ee54deb5-3024-47c2-be01-7c93faa6638a")] | |||
public void StartLogging() | |||
{ | |||
this.StopLogging(); | |||
EcoLogSwitches.LogOcl = this.LogOcl; | |||
EcoLogSwitches.LogEAL = this.LogEAL; | |||
EcoLogSwitches.LogPMapper = this.LogPMapper; | |||
EcoLogSwitches.LogSql = this.LogSql; | |||
EcoLogSwitches.LogSqlMeta = this.LogSqlMeta; | |||
EcoLogSwitches.LogActionExecute = this.LogActionExecute; | |||
EcoLogSwitches.LogActionEnable = this.LogActionEnable; | |||
EcoLogSwitches.LogMethods = this.LogMethods; | |||
EcoLogSwitches.CollectAssociationUsageStats = this.CollectAssociationUsageStats; | |||
EcoLogSwitches.LogWecpof = this.LogWecpof; | |||
EcoListener.Singleton.OnTraceLog += Singleton_OnTraceLog; | |||
EcoListener.StartListening(); | |||
} | |||
[UmlElement(Id = "ace10ea6-8793-4205-a2eb-9f22b9391701")] | |||
public string GetLog() | |||
{ | |||
string text = sb.ToString(); | |||
sb.Clear(); | |||
return text; | |||
} | |||
[UmlElement(Id = "3d2941f2-75ca-4a41-a5e8-465ddcfa2904")] | |||
public void StopLogging() | |||
{ | |||
EcoListener.Singleton.OnTraceLog -= Singleton_OnTraceLog; | |||
Eco.Logging.EcoListener.StopListening(); | |||
} | |||
[UmlElement(Id = "a4e7d189-a056-4be4-8e07-ea42d72505ac")] | |||
public string GetUsageStats() | |||
{ | |||
StringBuilder stats = new StringBuilder(); | |||
lock (EcoSupport.AssociationUsageStats) | |||
{ | |||
if (EcoSupport.AssociationUsageStats.Count > 0) | |||
{ | |||
foreach (KeyValuePair<string, int> x in EcoSupport.AssociationUsageStats) | |||
{ | |||
stats.AppendLine(x.Key + " = " + x.Value.ToString()); | |||
} | |||
} | |||
else | |||
stats.AppendLine("No stats in log"); | |||
} | |||
return stats.ToString(); | |||
} | |||
} | |||
} |
Revision as of 14:08, 16 July 2022
You can expand your TK app with OCL logging of your own making if you are using CodeDress.
public partial class SysLogging { StringBuilder sb = new StringBuilder(100000); void Singleton_OnTraceLog(object sender, Eco.Logging.TraceEventArgs e) { if (sb.Length > 5000000) sb.Clear(); sb.AppendLine(e.Message); } [UmlElement(Id = "ee54deb5-3024-47c2-be01-7c93faa6638a")] public void StartLogging() { this.StopLogging(); EcoLogSwitches.LogOcl = this.LogOcl; EcoLogSwitches.LogEAL = this.LogEAL; EcoLogSwitches.LogPMapper = this.LogPMapper; EcoLogSwitches.LogSql = this.LogSql; EcoLogSwitches.LogSqlMeta = this.LogSqlMeta; EcoLogSwitches.LogActionExecute = this.LogActionExecute; EcoLogSwitches.LogActionEnable = this.LogActionEnable; EcoLogSwitches.LogMethods = this.LogMethods; EcoLogSwitches.CollectAssociationUsageStats = this.CollectAssociationUsageStats; EcoLogSwitches.LogWecpof = this.LogWecpof; EcoListener.Singleton.OnTraceLog += Singleton_OnTraceLog; EcoListener.StartListening(); } [UmlElement(Id = "ace10ea6-8793-4205-a2eb-9f22b9391701")] public string GetLog() { string text = sb.ToString(); sb.Clear(); return text; } [UmlElement(Id = "3d2941f2-75ca-4a41-a5e8-465ddcfa2904")] public void StopLogging() { EcoListener.Singleton.OnTraceLog -= Singleton_OnTraceLog; Eco.Logging.EcoListener.StopListening(); } [UmlElement(Id = "a4e7d189-a056-4be4-8e07-ea42d72505ac")] public string GetUsageStats() { StringBuilder stats = new StringBuilder(); lock (EcoSupport.AssociationUsageStats) { if (EcoSupport.AssociationUsageStats.Count > 0) { foreach (KeyValuePair<string, int> x in EcoSupport.AssociationUsageStats) { stats.AppendLine(x.Key + " = " + x.Value.ToString()); } } else stats.AppendLine("No stats in log"); } return stats.ToString(); } } }
This page was edited more than 1 years ago on 12/20/2023. What links here