diff options
author | Thomas White <taw@physics.org> | 2020-03-18 12:01:18 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2020-07-29 18:42:57 +0200 |
commit | f5fca86eb191f41dfc45cf5c7f17e9ffd73d0287 (patch) | |
tree | be7773b16ed0d2708931a3c388bff34b3c9d996c /libcrystfel/src/utils.h | |
parent | 3022757e31b93542f332bcc1c323f63a853b7912 (diff) |
libcrystfel plumbing to allow ERROR/STATUS messages in GUI
Diffstat (limited to 'libcrystfel/src/utils.h')
-rw-r--r-- | libcrystfel/src/utils.h | 36 |
1 files changed, 13 insertions, 23 deletions
diff --git a/libcrystfel/src/utils.h b/libcrystfel/src/utils.h index f406ef6c..fcdde453 100644 --- a/libcrystfel/src/utils.h +++ b/libcrystfel/src/utils.h @@ -193,29 +193,19 @@ static inline int within_tolerance(double a, double b, double percent) #define ph_eV_to_k(a) ((a)*ELECTRON_CHARGE/PLANCK/C_VACUO) -/* ------------------------------ Message macros ---------------------------- */ - -extern pthread_mutex_t stderr_lock; - -#define ERROR(...) { \ - int error_print_val = get_status_label(); \ - pthread_mutex_lock(&stderr_lock); \ - if ( error_print_val >= 0 ) { \ - fprintf(stderr, "%3i: ", error_print_val); \ - } \ - fprintf(stderr, __VA_ARGS__); \ - pthread_mutex_unlock(&stderr_lock); \ - } - -#define STATUS(...) { \ - int status_print_val = get_status_label(); \ - pthread_mutex_lock(&stderr_lock); \ - if ( status_print_val >= 0 ) { \ - fprintf(stderr, "%3i: ", status_print_val); \ - } \ - fprintf(stderr, __VA_ARGS__); \ - pthread_mutex_unlock(&stderr_lock); \ - } +/* ------------------------------ Message logging ---------------------------- */ + + +enum log_msg_type { + LOG_MSG_STATUS, + LOG_MSG_ERROR +}; + + +extern void STATUS(const char *format, ...); +extern void ERROR(const char *format, ...); + +extern void set_log_message_func(void (*new_log_msg_func)(enum log_msg_type type, const char *)); /* ------------------------------ File handling ----------------------------- */ |