Log : add colors into logs
authorJin Yoon <jinny.yoon@samsung.com>
Sun, 14 Jun 2015 16:23:12 +0000 (01:23 +0900)
committerJin Yoon <jinny.yoon@samsung.com>
Sun, 14 Jun 2015 16:23:12 +0000 (01:23 +0900)
Change-Id: I74201993a5ff08e9060ca434cb70aa4d68f7c6c2

.gitignore
inc/log.h
inc/util.h
src/db.c

index 65fa71e..d8de857 100644 (file)
@@ -1,2 +1,3 @@
 /Debug
 /SA_Report
+/Release
index 15afdca..5c98907 100644 (file)
--- a/inc/log.h
+++ b/inc/log.h
@@ -1,38 +1,28 @@
-/*
- * Samsung API
- * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/license/
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __ADVENTURE_LOG_H__
-#define __ADVENTURE_LOG_H__
+#ifndef __YOUR_APPLICATION_LOG_H__
+#define __YOUR_APPLICATION_LOG_H__
 
 #include <dlog.h>
 
 #undef LOG_TAG
-#define LOG_TAG "ADVENTURE"
+#define LOG_TAG "YOUR_APPLICATION"
+
+#define COLOR_RED           "\033[0;40;31m"
+#define COLOR_LIGHTBLUE     "\033[1;40;34m"
+#define COLOR_YELLOW        "\033[1;40;33m"
+#define COLOR_END           "\033[0;m"
+#define COLOR_GRAY          "\033[1;40;30m"
+#define COLOR_MAGENTA       "\033[1;35m"
 
 #if !defined(_D)
-#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, fmt"\n", ##arg)
+#define _D(fmt, arg...) dlog_print(DLOG_DEBUG, LOG_TAG, COLOR_YELLOW fmt COLOR_END"\n", ##arg)
 #endif
 
 #if !defined(_W)
-#define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, fmt"\n", ##arg)
+#define _W(fmt, arg...) dlog_print(DLOG_WARN, LOG_TAG, COLOR_GRAY fmt COLOR_END"\n", ##arg)
 #endif
 
 #if !defined(_E)
-#define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, fmt"\n", ##arg)
+#define _E(fmt, arg...) dlog_print(DLOG_ERROR, LOG_TAG, COLOR_RED fmt COLOR_END"\n", ##arg)
 #endif
 
 #define retv_if(expr, val) do { \
@@ -70,4 +60,4 @@
        } \
 }
 
-#endif                         /* __ADVENTURE_LOG_H__ */
+#endif                         /* __YOUR_APPLICATION_LOG_H__ */
index 042f340..5c52759 100644 (file)
@@ -1,4 +1,12 @@
 /*
+
+
+
+
+
+
+
+
  * Samsung API
  * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd.
  *
index bec0518..a16ce3c 100644 (file)
--- a/src/db.c
+++ b/src/db.c
@@ -40,7 +40,7 @@ HAPI sqlite3 *db_open(void)
        int ret = SQLITE_OK;
 
        path = app_get_data_path();
-       retv_if(!path, APPL_ERROR_FAIL);
+       retv_if(!path, NULL);
        
        snprintf(db_file, sizeof(db_file), "%s/%s", path, APP_DB_FILE);
 
@@ -394,7 +394,7 @@ HAPI appl_error_e db_drop_table(sqlite3 *db)
        count = sizeof(TABLES) / sizeof(char *);
        for (; i < count; i++) {
                _D("Drop a table[%s]", TABLES[i]);
-               break_if(db_exec(TABLES[i]) != APPL_ERROR_NONE);
+               break_if(db_exec(db, TABLES[i]) != APPL_ERROR_NONE);
        }
 
        return APPL_ERROR_FAIL;