opkg: add default message handler
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:15:42 +0000 (05:15 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 15 Dec 2008 05:15:42 +0000 (05:15 +0000)
git-svn-id: http://opkg.googlecode.com/svn/trunk@103 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_message.c

index 980d6a7..98b3c9d 100644 (file)
@@ -26,11 +26,18 @@ opkg_message (opkg_conf_t * conf, message_level_t level, char *fmt, ...)
        va_list ap;
        char ts[256];
 
+       va_start (ap, fmt);
+       vsnprintf (ts,256,fmt, ap);
+       va_end (ap);
+
        if (opkg_cb_message)
        {
-               va_start (ap, fmt);
-               vsnprintf (ts,256,fmt, ap);
-               va_end (ap);
                opkg_cb_message(conf,level,ts);
        }
+       else
+       {
+         char *level_s[5] = {"ERROR", "NOTICE", "INFO", "DEBUG", "DEBUG2"};
+         if (level <= conf->verbosity)
+           printf ("opkg-%s: %s", level_s[level], ts);
+       }
 }