adding timestamp to crashdump
authorVolker Birk <vb@pep-project.org>
Sun, 21 Feb 2016 12:00:51 +0100
changeset 4527600b9f9ee9c
parent 451 495e53a4b441
child 453 f6a197a72f1f
adding timestamp to crashdump
src/pEpEngine.c
test/crashdump_test.cc
     1.1 --- a/src/pEpEngine.c	Sun Feb 21 11:43:15 2016 +0100
     1.2 +++ b/src/pEpEngine.c	Sun Feb 21 12:00:51 2016 +0100
     1.3 @@ -202,7 +202,7 @@
     1.4  
     1.5          sql_mark_as_compromized = "update trust not indexed set comm_type = 15 where pgp_keypair_fpr = ?1 ;";
     1.6  
     1.7 -        sql_crashdump = "select title, entity, description, comment from log order by timestamp desc limit ?1 ;";
     1.8 +        sql_crashdump = "select timestamp, title, entity, description, comment from log order by timestamp desc limit ?1 ;";
     1.9      }
    1.10  
    1.11      int_result = sqlite3_prepare_v2(_session->db, sql_log, (int)strlen(sql_log),
    1.12 @@ -1084,13 +1084,14 @@
    1.13          return PEP_ILLEGAL_VALUE;
    1.14  
    1.15      int limit = maxlines ? maxlines : CRASHDUMP_DEFAULT_LINES;
    1.16 +    const char *timestamp;
    1.17      const char *title;
    1.18      const char *entity;
    1.19      const char *desc;
    1.20      const char *comment;
    1.21  
    1.22      sqlite3_reset(session->crashdump);
    1.23 -	sqlite3_bind_int(session->crashdump, 1, limit);
    1.24 +    sqlite3_bind_int(session->crashdump, 1, limit);
    1.25  
    1.26      int result;
    1.27  
    1.28 @@ -1098,10 +1099,15 @@
    1.29          result = sqlite3_step(session->crashdump);
    1.30          switch (result) {
    1.31          case SQLITE_ROW:
    1.32 -            title   = (const char *) sqlite3_column_text(session->crashdump, 0);
    1.33 -            entity  = (const char *) sqlite3_column_text(session->crashdump, 1);
    1.34 -            desc    = (const char *) sqlite3_column_text(session->crashdump, 2);
    1.35 -            comment = (const char *) sqlite3_column_text(session->crashdump, 3);
    1.36 +            timestamp = (const char *) sqlite3_column_text(session->crashdump, 0);
    1.37 +            title   = (const char *) sqlite3_column_text(session->crashdump, 1);
    1.38 +            entity  = (const char *) sqlite3_column_text(session->crashdump, 2);
    1.39 +            desc    = (const char *) sqlite3_column_text(session->crashdump, 3);
    1.40 +            comment = (const char *) sqlite3_column_text(session->crashdump, 4);
    1.41 +
    1.42 +            _logdata = _concat_string(_logdata, timestamp, ',');
    1.43 +            if (_logdata == NULL)
    1.44 +                goto enomem;
    1.45  
    1.46              _logdata = _concat_string(_logdata, title, ',');
    1.47              if (_logdata == NULL)
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/crashdump_test.cc	Sun Feb 21 12:00:51 2016 +0100
     2.3 @@ -0,0 +1,30 @@
     2.4 +#include <iostream>
     2.5 +#include <string>
     2.6 +#include <assert.h>
     2.7 +#include "pEpEngine.h"
     2.8 +
     2.9 +using namespace std;
    2.10 +
    2.11 +int main() {
    2.12 +    cout << "\n*** MODULE_test ***\n\n";
    2.13 +
    2.14 +    PEP_SESSION session;
    2.15 +    
    2.16 +    cout << "calling init()\n";
    2.17 +    PEP_STATUS status1 = init(&session);   
    2.18 +    assert(status1 == PEP_STATUS_OK);
    2.19 +    assert(session);
    2.20 +    cout << "init() completed.\n";
    2.21 +
    2.22 +    // MODULE test code
    2.23 +
    2.24 +    char *text;
    2.25 +    PEP_STATUS status2 = get_crashdump_log(session, 10, &text);
    2.26 +    assert(status2 == PEP_STATUS_OK);
    2.27 +    cout << text;
    2.28 +
    2.29 +    cout << "calling release()\n";
    2.30 +    release(session);
    2.31 +    return 0;
    2.32 +}
    2.33 +