Wiki source code of EOF-Using EOF-Logging

Last modified by Maik Musall on 2012/07/01 19:35

Hide last authors
Pascal Robert 4.1 1 == Overview ==
smmccraw 1.1 2
Maik Musall 7.1 3 You can turn SQL logging on when launching by using -DEOAdaptorDebugEnabled=true or EOAdaptorDebugEnabled YES. However, this can slam out a ton of SQL. While this is useful for some debugging it is way too much to sift through when trying to analyze a particular problem.
smmccraw 1.1 4
5 You can use this method to selectively enable and disable SQL logging:
6
Quinton Dolan 3.1 7 {{code}}
smmccraw 1.1 8
Quinton Dolan 3.1 9 public static void logSQL(boolean shouldLog) {
10 if (shouldLog) {
11 NSLog.allowDebugLoggingForGroups(NSLog.DebugGroupSQLGeneration |
Pascal Robert 4.1 12 NSLog.DebugGroupDatabaseAccess |
Quinton Dolan 3.1 13 NSLog.DebugGroupEnterpriseObjects);
14 } else {
Pascal Robert 4.1 15 NSLog.refuseDebugLoggingForGroups(NSLog.DebugGroupSQLGeneration |
Quinton Dolan 3.1 16 NSLog.DebugGroupDatabaseAccess |
17 NSLog.DebugGroupEnterpriseObjects);
smmccraw 1.1 18 }
Quinton Dolan 3.1 19 }
smmccraw 1.1 20
Quinton Dolan 3.1 21 {{/code}}
smmccraw 1.1 22
23 This can be useful for such things as determining what fetches are performed when a page is rendered:
24
Quinton Dolan 3.1 25 {{code}}
smmccraw 1.1 26
Quinton Dolan 3.1 27 public void appendToResponse(WOResponse aResponse,
28 WOContext aContext) {
29 logSQL(true);
30 super.appendToResponse(aResponse, aContext);
31 logSQL(false);
32 }
smmccraw 1.1 33
Quinton Dolan 3.1 34 {{/code}}
Maik Musall 5.1 35
Maik Musall 7.1 36 (% style="color: rgb(0,109,175);" %)[[WO:Here is an awk script>>attach:eosql.awk]](%%) that takes an a WOApplication log which contains EOAdaptorLog info as input, picks out the SQL statements and their bindings, and spits out a CSV formatted log of those statements, with binding values filled in as literals, along with rowcount and execution time in seconds. Those statements can most of the time be used manually against a database for testing purposes. You need gawk installed for this.