Android sql logging fix (can apply to other branches later if it works) 2.0.5_p4a_log_test
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 17 Jun 2020 19:28:48 +0200
branch2.0.5_p4a_log_test
changeset 474885cfc14aaa20
parent 4701 3db667f48863
child 4749 c276c93c972f
Android sql logging fix (can apply to other branches later if it works)
src/pEpEngine.c
src/pgp_sequoia.c
     1.1 --- a/src/pEpEngine.c	Mon May 11 10:38:13 2020 +0200
     1.2 +++ b/src/pEpEngine.c	Wed Jun 17 19:28:48 2020 +0200
     1.3 @@ -46,25 +46,33 @@
     1.4                          void* context_ptr,
     1.5                          void* P,
     1.6                          void* X) {
     1.7 +                            
     1.8 +    const char* TC_str = "";
     1.9 +    const char* info_str = "";
    1.10 +    const char* title = "SQL_DEBUG";
    1.11 +                                
    1.12      switch (trace_constant) {
    1.13          case SQLITE_TRACE_STMT:
    1.14 -            fprintf(stderr, "SQL_DEBUG: STMT - ");
    1.15 -            const char* X_str = (const char*) X;
    1.16 -            if (!EMPTYSTR(X_str) && X_str[0] == '-' && X_str[1] == '-')
    1.17 -                fprintf(stderr, "%s\n", X_str);
    1.18 -            else
    1.19 -                fprintf(stderr, "%s\n", sqlite3_expanded_sql((sqlite3_stmt*)P));    
    1.20 +            TC_str = "STMT";
    1.21 +            info_str = (const char*) X;
    1.22 +            if (EMPTYSTR(info_str) || info_str[0] != '-' || info_str[1] != '-')
    1.23 +                info_str = sqlite3_expanded_sql((sqlite3_stmt*)P);
    1.24              break;
    1.25          case SQLITE_TRACE_ROW:
    1.26 -            fprintf(stderr, "SQL_DEBUG: ROW - ");
    1.27 -            fprintf(stderr, "%s\n", sqlite3_expanded_sql((sqlite3_stmt*)P));
    1.28 -            break;            
    1.29 +            TC_str = "ROW";
    1.30 +            info_str = sqlite3_expanded_sql((sqlite3_stmt*)P);
    1.31 +            break;
    1.32          case SQLITE_TRACE_CLOSE:
    1.33 -            fprintf(stderr, "SQL_DEBUG: CLOSE - ");
    1.34 +            TC_str = "CLOSE";
    1.35              break;
    1.36          default:
    1.37              break;
    1.38      }
    1.39 +#ifndef ANDROID
    1.40 +    fprintf(stderr, "%s: %s - %s\n", title, TC_str, info_str);
    1.41 +#else
    1.42 +    log_event(session, title, TC_str, info_str, NULL);
    1.43 +#endif    
    1.44      return 0;
    1.45  }
    1.46  #endif
     2.1 --- a/src/pgp_sequoia.c	Mon May 11 10:38:13 2020 +0200
     2.2 +++ b/src/pgp_sequoia.c	Wed Jun 17 19:28:48 2020 +0200
     2.3 @@ -100,25 +100,33 @@
     2.4                          void* context_ptr,
     2.5                          void* P,
     2.6                          void* X) {
     2.7 +    const char* TC_str = "";
     2.8 +    const char* info_str = "";
     2.9 +    const char* title = "SEQUOIA_SQL_DEBUG";
    2.10 +                                
    2.11      switch (trace_constant) {
    2.12          case SQLITE_TRACE_STMT:
    2.13 -            fprintf(stderr, "SEQUOIA_SQL_DEBUG: STMT - ");
    2.14 -            const char* X_str = (const char*) X;
    2.15 -            if (!EMPTYSTR(X_str) && X_str[0] == '-' && X_str[1] == '-')
    2.16 -                fprintf(stderr, "%s\n", X_str);
    2.17 -            else
    2.18 -                fprintf(stderr, "%s\n", sqlite3_expanded_sql((sqlite3_stmt*)P));
    2.19 +            TC_str = "STMT";
    2.20 +            info_str = (const char*) X;
    2.21 +            if (EMPTYSTR(info_str) || info_str[0] != '-' || info_str[1] != '-')
    2.22 +                info_str = sqlite3_expanded_sql((sqlite3_stmt*)P);
    2.23              break;
    2.24          case SQLITE_TRACE_ROW:
    2.25 -            fprintf(stderr, "SEQUOIA_SQL_DEBUG: ROW - ");
    2.26 -            fprintf(stderr, "%s\n", sqlite3_expanded_sql((sqlite3_stmt*)P));
    2.27 +            TC_str = "ROW";
    2.28 +            info_str = sqlite3_expanded_sql((sqlite3_stmt*)P);
    2.29              break;
    2.30          case SQLITE_TRACE_CLOSE:
    2.31 -            fprintf(stderr, "SEQUOIA_SQL_DEBUG: CLOSE - ");
    2.32 +            TC_str = "CLOSE";
    2.33              break;
    2.34          default:
    2.35              break;
    2.36      }
    2.37 +
    2.38 +#ifndef ANDROID
    2.39 +    fprintf(stderr, "%s: %s - %s\n", title, TC_str, info_str);
    2.40 +#else
    2.41 +    log_event(session, title, TC_str, info_str, NULL);
    2.42 +#endif    
    2.43      return 0;
    2.44  }
    2.45  #endif