Logging OCL in Turnkey
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
You can expand your TK app with OCL logging | You can expand your TK app with your own OCL logging if you are using CodeDress. | ||
This will work and have the same features as the designer's built in logging. | This will work and have the same features as the designer's built-in logging. | ||
Create a transient and singleton class like this | Create a transient and singleton class like this: | ||
[[File:SysLoggingClass.png|none|thumb|290x290px]]Add code similar to the one at the bottom of this page to the class methods. | [[File:SysLoggingClass.png|none|thumb|290x290px]]Add code similar to the one at the bottom of this page to the class methods. | ||
Create a | Create a ViewModel like the example below to use the class:[[File:SysLoggingViewmodel.png|none|thumb|517x517px]] | ||
[[File:SysLoggingView.png|none|thumb|554x554px]] | [[File:SysLoggingView.png|none|thumb|554x554px]] | ||
I created a variable on the view with the name vLogText. | I created a variable on the view with the name vLogText. | ||
GetLog action does this | GetLog action does this: | ||
vLogText := self.GetLog | vLogText := self.GetLog | ||
GetUsageStats action does this | GetUsageStats action does this: | ||
vLogText := self.GetUsageStats | vLogText := self.GetUsageStats | ||
The method SO() is a shortcut for | The method SO() is a shortcut for: | ||
SysLogging.oclSingleton | SysLogging.oclSingleton | ||
Code for the class | Code for the class: | ||
public partial class SysLogging | public partial class SysLogging | ||
Line 84: | Line 84: | ||
} | } | ||
} | } | ||
See also: [[Logging what MDriven does]] | |||
Keywords: debugging OCL, logging, performance | Keywords: debugging OCL, logging, performance | ||
[[Category:Advanced]] | [[Category:Advanced]] |
Revision as of 07:24, 7 March 2023
You can expand your TK app with your own OCL logging if you are using CodeDress.
This will work and have the same features as the designer's built-in logging.
Create a transient and singleton class like this:
Add code similar to the one at the bottom of this page to the class methods. Create a ViewModel like the example below to use the class:
I created a variable on the view with the name vLogText.
GetLog action does this:
vLogText := self.GetLog
GetUsageStats action does this:
vLogText := self.GetUsageStats
The method SO() is a shortcut for:
SysLogging.oclSingleton
Code for the class:
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(); } } }
See also: Logging what MDriven does
Keywords: debugging OCL, logging, performance
This page was edited more than 1 years ago on 12/20/2023. What links here