From 0181ccabad8b1beff1773859c10c1aec7a493db2 Mon Sep 17 00:00:00 2001 From: Jiyong Min Date: Tue, 23 Jan 2018 11:24:34 +0900 Subject: [PATCH] Add the debug mode for GraphicsMagick Change-Id: I87cd4c5018d5ce51a8aeaeec66bcaf6e8f78bec6 --- magick/mm_util_magick.c | 42 +++++++++++++++++++++++++++++++++++++++++- packaging/libmm-utility.spec | 2 +- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/magick/mm_util_magick.c b/magick/mm_util_magick.c index b22db46..486c4de 100755 --- a/magick/mm_util_magick.c +++ b/magick/mm_util_magick.c @@ -34,13 +34,53 @@ typedef struct _util_image_s { static bool __mm_util_check_angle(mm_util_magick_rotate_type angle); +static void __mm_util_magick_log_method(const ExceptionType excep, const char *message) +{ + /* To exclude time, user time and pid */ + unsigned int start_idx = 31; + + if ((message == NULL) || (strlen(message) < start_idx)) { + start_idx = 0; + } + + if (excep >= ErrorException) + mm_util_error("[GM][Ex:%3u] %s", excep, message + start_idx); + else if (excep >= WarningException) + mm_util_warn("[GM][Ex:%3u] %s", excep, message + start_idx); + else + mm_util_debug("[GM][Ex:%3u] %s", excep, message + start_idx); +} + +static void __mm_util_magick_error_handler(const ExceptionType excep, const char *reason, const char *message) +{ + if (excep >= ErrorException) + mm_util_error("[GM][Ex:%3u][Rs:%s] %s", excep, reason, message); + else + mm_util_warn("[GM][Ex:%3u][Rs:%s] %s", excep, reason, message); +} + static void __mm_util_init(ExceptionInfo *exception) { InitializeMagick(NULL); - if (exception != NULL) GetExceptionInfo(exception); + /* set LogEventMask to show like "all" or "warning, error" */ + /* + * "none", "information", "warning", "error", "fatalerror", "configure", "annotate", + * "render", "transform", "locale", "coder", "x11", "cache", "blob", "deprecate", + * "user", "resource", "temporaryfile", "exception", "option", "all" + */ +#if (GMAGICK_DEBUG == 1) + SetLogEventMask("all"); +#else + SetLogEventMask("warning, error, fatalerror, exception"); +#endif + SetLogMethod(__mm_util_magick_log_method); + SetErrorHandler(__mm_util_magick_error_handler); + SetFatalErrorHandler(__mm_util_magick_error_handler); + SetWarningHandler(__mm_util_magick_error_handler); + return; } diff --git a/packaging/libmm-utility.spec b/packaging/libmm-utility.spec index 12b905b..a62db13 100755 --- a/packaging/libmm-utility.spec +++ b/packaging/libmm-utility.spec @@ -41,7 +41,7 @@ Multimedia Framework Utility Library - Development files. cp %{SOURCE1001} . %build -export CFLAGS="$CFLAGS -DSYSCONFDIR=\\\"%{_sysconfdir}\\\"" +export CFLAGS="$CFLAGS -DGMAGICK_DEBUG=0" %cmake . make %{?jobs:-j%jobs} -- 2.7.4