Browse Source

extending logging features

doc_update_sequoia
Volker Birk 5 years ago
parent
commit
528b11853b
3 changed files with 48 additions and 6 deletions
  1. +24
    -2
      src/pEpEngine.c
  2. +19
    -0
      src/pEpEngine.h
  3. +5
    -4
      src/pEp_internal.h

+ 24
- 2
src/pEpEngine.c View File

@ -843,6 +843,12 @@ DYNAMIC_API void config_keep_sync_msg(PEP_SESSION session, bool enable)
session->keep_sync_msg = enable;
}
DYNAMIC_API void config_service_log(PEP_SESSION session, bool enable)
{
assert(session);
session->service_log = enable;
}
DYNAMIC_API PEP_STATUS log_event(
PEP_SESSION session,
const char *title,
@ -883,6 +889,24 @@ DYNAMIC_API PEP_STATUS log_event(
return ERROR(status);
}
DYNAMIC_API PEP_STATUS log_service(
PEP_SESSION session,
const char *title,
const char *entity,
const char *description,
const char *comment
)
{
assert(session);
if (!session)
return PEP_ILLEGAL_VALUE;
if (session->service_log)
return log_event(session, title, entity, description, comment);
else
return PEP_STATUS_OK;
}
DYNAMIC_API PEP_STATUS trustword(
PEP_SESSION session, uint16_t value, const char *lang,
char **word, size_t *wsize
@ -1283,8 +1307,6 @@ PEP_STATUS replace_identities_fpr(PEP_SESSION session,
const char* old_fpr,
const char* new_fpr)
{
PEP_STATUS status = PEP_STATUS_OK;
assert(old_fpr);
assert(new_fpr);


+ 19
- 0
src/pEpEngine.h View File

@ -202,6 +202,14 @@ DYNAMIC_API void config_use_only_own_private_keys(PEP_SESSION session, bool enab
DYNAMIC_API void config_keep_sync_msg(PEP_SESSION session, bool enable);
// config_service_log() - log more for service purposes
//
// session (in) session handle
// enable (in) flag if enabled or disabled
DYNAMIC_API void config_service_log(PEP_SESSION session, bool enable);
// decrypt_and_verify() - decrypt and/or verify a message
//
// parameters:
@ -316,6 +324,17 @@ DYNAMIC_API PEP_STATUS log_event(
);
DYNAMIC_API PEP_STATUS log_service(PEP_SESSION session, const char *title,
const char *entity, const char *description, const char *comment);
#define _STR_(x) #x
#define _D_STR_(x) _STR_(x)
#define S_LINE _D_STR_(__LINE__)
#define SERVICE_LOG(session, title, entity, desc) \
log_service((session), (title), (entity), (desc), "service " __FILE__ ":" S_LINE)
// trustword() - get the corresponding trustword for a 16 bit value
//
// parameters:


+ 5
- 4
src/pEp_internal.h View File

@ -162,6 +162,7 @@ struct _pEpSession {
bool passive_mode;
bool unencrypted_subject;
bool keep_sync_msg;
bool service_log;
#ifdef DEBUG_ERRORSTACK
stringlist_t* errorstack;
@ -183,14 +184,14 @@ PEP_STATUS encrypt_only(
#else
#ifdef ANDROID
#include <android/log.h>
#define LOG_MORE(...) __android_log_print(ANDROID_LOG_DEBUG, "pEpEngine", " %s :: %s :: %s ", __VA_ARGS__);
#define LOG_MORE(...) __android_log_print(ANDROID_LOG_DEBUG, "pEpEngine", " %s :: %s :: %s :: %s ", __VA_ARGS__);
#else
#include <stdio.h>
#define LOG_MORE(...) printf("pEpEngine DEBUG_LOG('%s','%s','%s')\n", __VA_ARGS__);
#define LOG_MORE(...) fprintf(stderr, "pEpEngine DEBUG_LOG('%s','%s','%s','%s')\n", __VA_ARGS__);
#endif
#define DEBUG_LOG(TITLE, ENTITY, DESC) {\
log_event(session, (TITLE), (ENTITY), (DESC), "debug");\
LOG_MORE((TITLE), (ENTITY), (DESC))\
log_event(session, (TITLE), (ENTITY), (DESC), "debug " __FILE__ ":" S_LINE);\
LOG_MORE((TITLE), (ENTITY), (DESC), __FILE__ ":" S_LINE)\
}
#endif


Loading…
Cancel
Save