Add the debug mode for GraphicsMagick 06/167906/7
authorJiyong Min <jiyong.min@samsung.com>
Tue, 23 Jan 2018 02:24:34 +0000 (11:24 +0900)
committerJiyong Min <jiyong.min@samsung.com>
Wed, 24 Jan 2018 06:21:49 +0000 (15:21 +0900)
Change-Id: I87cd4c5018d5ce51a8aeaeec66bcaf6e8f78bec6

magick/mm_util_magick.c
packaging/libmm-utility.spec

index b22db46..486c4de 100755 (executable)
@@ -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" */
+       /* <LogEventMask List>
+        * "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;
 }
 
index 12b905b..a62db13 100755 (executable)
@@ -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}