Revise log related code 43/245743/4
authorJeongmo Yang <jm80.yang@samsung.com>
Thu, 15 Oct 2020 08:01:17 +0000 (17:01 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Fri, 16 Oct 2020 01:31:23 +0000 (10:31 +0900)
1. Set default log level - MM_CAMCORDER_LOG_LEVEL_INFO
2. Fix bug : Log level is not applied when audio only recording mode
3. Change level for some log
4. Remove unnecessary comment

[Version] 0.10.217
[Issue Type] Log feature

Change-Id: I1b775b23d201f436ccc34e7b231dbe78306fad92
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/libmm-camcorder.spec
src/mm_camcorder_configure.c
src/mm_camcorder_internal.c
src/mm_camcorder_platform.c

index 164aaf6..6fe9b78 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmm-camcorder
 Summary:    Camera and recorder library
-Version:    0.10.216
+Version:    0.10.217
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0
index 661e5a2..e01f642 100644 (file)
@@ -1002,7 +1002,7 @@ int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera
                        buffer_line_size = MMCAMCORDER_BUFFER_LINE_MAX;
                        length_read = getline(&buffer_string, &buffer_line_size, fp);
                        if (length_read < 1) {
-                               MMCAM_LOG_WARNING("skip this case - length read[%d]", length_read);
+                               MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
                                continue;
                        }
 
@@ -1048,7 +1048,7 @@ int _mmcamcorder_conf_parse_info(MMHandleType handle, int type, FILE *fp, camera
                        while (!feof(fp)) {
                                length_read = getline(&buffer_string, &buffer_line_size, fp);
                                if (length_read < 1) {
-                                       MMCAM_LOG_WARNING("skip this case - length read[%d]", length_read);
+                                       MMCAM_LOG_DEBUG("skip this case - length read[%d]", length_read);
                                        continue;
                                }
 
@@ -1573,7 +1573,7 @@ int _mmcamcorder_conf_get_value_int(MMHandleType handle, camera_conf* configure_
        int i, count;
        conf_detail* info;
 
-       MMCAM_LOG_DEBUG("category[%d],name[%s]", category, name);
+       MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
 
        mmf_return_val_if_fail(configure_info, FALSE);
        mmf_return_val_if_fail(name, FALSE);
@@ -1599,7 +1599,7 @@ int _mmcamcorder_conf_get_value_int(MMHandleType handle, camera_conf* configure_
                return TRUE;
        }
 
-       MMCAM_LOG_ERROR("Failed to get int. Category[%d],Name[%s]", category, name);
+       MMCAM_LOG_DEBUG("Failed to get [%s]", name);
 
        return FALSE;
 }
@@ -1610,7 +1610,7 @@ _mmcamcorder_conf_get_value_int_range(camera_conf* configure_info, int category,
        int i, count;
        conf_detail* info;
 
-       MMCAM_LOG_DEBUG("category[%d],name[%s]", category, name);
+       MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
 
        mmf_return_val_if_fail(configure_info, FALSE);
        mmf_return_val_if_fail(name, FALSE);
@@ -1634,7 +1634,7 @@ _mmcamcorder_conf_get_value_int_range(camera_conf* configure_info, int category,
 
        *value = NULL;
 
-       MMCAM_LOG_ERROR("Failed to get int range. Category[%d],Name[%s]", category, name);
+       MMCAM_LOG_DEBUG("Failed to get [%s]", name);
 
        return FALSE;
 }
@@ -1644,7 +1644,7 @@ int _mmcamcorder_conf_get_value_int_array(camera_conf* configure_info, int categ
        int i, count;
        conf_detail* info;
 
-       MMCAM_LOG_DEBUG("category[%d],name[%s]", category, name);
+       MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
 
        mmf_return_val_if_fail(configure_info, FALSE);
        mmf_return_val_if_fail(name, FALSE);
@@ -1668,7 +1668,7 @@ int _mmcamcorder_conf_get_value_int_array(camera_conf* configure_info, int categ
 
        *value = NULL;
 
-       MMCAM_LOG_ERROR("Failed to get int array. Category[%d],Name[%s]", category, name);
+       MMCAM_LOG_DEBUG("Failed to get [%s]", name);
 
        return FALSE;
 }
@@ -1679,7 +1679,7 @@ _mmcamcorder_conf_get_value_int_pair_array(camera_conf* configure_info, int cate
        int i, count;
        conf_detail* info;
 
-       MMCAM_LOG_DEBUG("category[%d],name[%s]", category, name);
+       MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
 
        mmf_return_val_if_fail(configure_info, FALSE);
        mmf_return_val_if_fail(name, FALSE);
@@ -1704,7 +1704,7 @@ _mmcamcorder_conf_get_value_int_pair_array(camera_conf* configure_info, int cate
 
        *value = NULL;
 
-       MMCAM_LOG_ERROR("Failed to get int pair array. Category[%d],Name[%s]", category, name);
+       MMCAM_LOG_DEBUG("Failed to get [%s]", name);
 
        return FALSE;
 }
@@ -1714,7 +1714,7 @@ int _mmcamcorder_conf_get_value_string(MMHandleType handle, camera_conf* configu
        int i, count;
        conf_detail* info;
 
-       MMCAM_LOG_DEBUG("category[%d],name[%s]", category, name);
+       MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
 
        mmf_return_val_if_fail(configure_info, FALSE);
        mmf_return_val_if_fail(name, FALSE);
@@ -1740,7 +1740,7 @@ int _mmcamcorder_conf_get_value_string(MMHandleType handle, camera_conf* configu
                return TRUE;
        }
 
-       MMCAM_LOG_ERROR("Failed to get string. Category[%d],Name[%s]", category, name);
+       MMCAM_LOG_DEBUG("Failed to get [%s]", name);
 
        return FALSE;
 }
@@ -1750,7 +1750,7 @@ int _mmcamcorder_conf_get_value_string_array(camera_conf* configure_info, int ca
        int i, count;
        conf_detail* info;
 
-       MMCAM_LOG_DEBUG("category[%d],name[%s]", category, name);
+       MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
 
        mmf_return_val_if_fail(configure_info, FALSE);
        mmf_return_val_if_fail(name, FALSE);
@@ -1774,7 +1774,7 @@ int _mmcamcorder_conf_get_value_string_array(camera_conf* configure_info, int ca
 
        *value = NULL;
 
-       MMCAM_LOG_ERROR("Failed to get string array. Category[%d],Name[%s]", category, name);
+       MMCAM_LOG_DEBUG("Failed to get [%s]", name);
 
        return FALSE;
 }
@@ -1784,7 +1784,7 @@ int _mmcamcorder_conf_get_element(MMHandleType handle, camera_conf* configure_in
        int i, count;
        conf_detail* info;
 
-       MMCAM_LOG_DEBUG("category[%d], name[%s]", category, name);
+       MMCAM_LOG_VERBOSE("category[%d], name[%s]", category, name);
 
        mmf_return_val_if_fail(configure_info, FALSE);
        mmf_return_val_if_fail(name, FALSE);
@@ -1810,7 +1810,7 @@ int _mmcamcorder_conf_get_element(MMHandleType handle, camera_conf* configure_in
                return TRUE;
        }
 
-       MMCAM_LOG_ERROR("Failed to get element name. Category[%d],Name[%s]", category, name);
+       MMCAM_LOG_ERROR("Failed to get [%s]", name);
 
        return FALSE;
 }
@@ -1886,7 +1886,7 @@ int _mmcamcorder_conf_set_value_element_property(GstElement* gst, type_element*
                for (i = 0 ; i < element->count_int ; i++) {
                        MMCAMCORDER_G_OBJECT_SET(gst, element->value_int[i]->name, element->value_int[i]->value);
 
-                       MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> integer[%d]",
+                       MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> [i:%d]",
                                element->element_name,
                                element->value_int[i]->name,
                                element->value_int[i]->value);
@@ -1904,7 +1904,7 @@ int _mmcamcorder_conf_set_value_element_property(GstElement* gst, type_element*
                for (i = 0 ; i < element->count_string ; i++) {
                        MMCAMCORDER_G_OBJECT_SET_POINTER(gst, element->value_string[i]->name, element->value_string[i]->value);
 
-                       MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> string[%s]",
+                       MMCAM_LOG_DEBUG("Element[%s] Set[%s] -> [s:%s]",
                                element->element_name,
                                element->value_string[i]->name,
                                element->value_string[i]->value);
index 6fd655b..24f4eb4 100644 (file)
@@ -46,7 +46,7 @@
 #endif /* _MMCAMCORDER_RM_SUPPORT */
 
 /* log level */
-int mmcam_log_level;
+int mmcam_log_level = MM_CAMCORDER_LOG_LEVEL_INFO;
 
 /*---------------------------------------------------------------------------------------
 |    LOCAL VARIABLE DEFINITIONS for internal                                           |
@@ -185,6 +185,12 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
                goto _INIT_HANDLE_FAILED;
        }
 
+       /* Get log level from conf */
+       _mmcamcorder_conf_get_value_int((MMHandleType)new_handle, new_handle->conf_main,
+               CONFIGURE_CATEGORY_MAIN_GENERAL,
+               "LogLevel",
+               &mmcam_log_level);
+
        /* allocate attribute */
        new_handle->attributes = _mmcamcorder_alloc_attribute((MMHandleType)new_handle);
        if (!new_handle->attributes) {
@@ -192,6 +198,13 @@ static gint __mmcamcorder_init_handle(mmf_camcorder_t **hcamcorder, int device_t
                goto _INIT_HANDLE_FAILED;
        }
 
+       /* Set log level to attribute */
+       ret = mm_camcorder_set_attributes((MMHandleType)new_handle, NULL,
+               MMCAM_LOG_LEVEL, mmcam_log_level,
+               NULL);
+
+       MMCAM_LOG_INFO("set log level[%d], ret[0x%x]", mmcam_log_level, ret);
+
        *hcamcorder = new_handle;
 
        MMCAM_LOG_INFO("new handle %p", new_handle);
@@ -476,15 +489,9 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                return MM_ERROR_CAMCORDER_INTERNAL;
        }
 
-       _mmcamcorder_conf_get_value_int((MMHandleType)hcamcorder, hcamcorder->conf_main,
-               CONFIGURE_CATEGORY_MAIN_GENERAL,
-               "LogLevel",
-               &mmcam_log_level);
-
-       MMCAM_LOG_INFO("ZeroCopy %d, UserBuffer %d, Videoconvert %d, MPPreviewCb %d, LogLevel %d",
+       MMCAM_LOG_INFO("ZeroCopy %d, UserBuffer %d, Videoconvert %d, MPPreviewCb %d",
                hcamcorder->use_zero_copy_format, hcamcorder->support_user_buffer,
-               hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb,
-               mmcam_log_level);
+               hcamcorder->use_videoconvert, hcamcorder->support_media_packet_preview_cb);
 
        MMCAM_LOG_INFO("res : %d X %d, Default FPS by resolution : %d",
                resolution_width, resolution_height, fps_info.int_array.def);
@@ -518,7 +525,6 @@ static gint __mmcamcorder_init_configure_video_capture(mmf_camcorder_t *hcamcord
                MMCAM_CAPTURE_SOUND_ENABLE, play_capture_sound,
                MMCAM_PLATFORM_PRIVILEGE_CAMERA, platform_privilege_camera,
                        platform_privilege_camera ? strlen(platform_privilege_camera) : 0,
-               MMCAM_LOG_LEVEL, mmcam_log_level,
                NULL);
        if (ret != MM_ERROR_NONE) {
                MMCAM_LOG_ERROR("[0x%x] Set %s FAILED.", ret, err_attr_name ? err_attr_name : "[UNKNOWN]");
index 4f87e9f..0533d0a 100644 (file)
@@ -939,7 +939,7 @@ int __mmcamcorder_set_info_to_attr(MMHandleType handle, _MMCamcorderInfoConverti
        camera_conf *conf_info = NULL;
 
        for (i = 0; i < table_size; i++) {
-               MMCAM_LOG_DEBUG("[type:%d][cat:%d][attr:%d][attr_pair:%d][key:%s][ctype:%d]",
+               MMCAM_LOG_VERBOSE("[type:%d][cat:%d][attr:%d][attr_pair:%d][key:%s][ctype:%d]",
                        info[i].type,
                        info[i].category,
                        info[i].attr_idx,
@@ -989,12 +989,10 @@ int __mmcamcorder_set_info_to_attr(MMHandleType handle, _MMCamcorderInfoConverti
                                }
 
                                if (iarray_size > 0) {
-                                       MMCAM_LOG_INFO("INT Array - size[%d], default[%d]", iarray_size, idefault);
+                                       MMCAM_LOG_DEBUG("[%s] INT Array - size[%d], default[%d]",
+                                               info[i].keyword, iarray_size, idefault);
 
-                                       /* "mm_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
-                                       /* mm_attrs_set_valid_type(attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_ARRAY); */
                                        mm_attrs_set_valid_array(attrs, info[i].attr_idx, iarray, iarray_size, idefault);
-
                                        ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, idefault);
                                }
                        }
@@ -1012,12 +1010,10 @@ int __mmcamcorder_set_info_to_attr(MMHandleType handle, _MMCamcorderInfoConverti
                                break; /* skip to set, but not error */
 
                        if (irange) {
-                               MMCAM_LOG_VERBOSE("INT Range - min[%d], max[%d]", irange->min, irange->max);
+                               MMCAM_LOG_DEBUG("[%s] INT Range - min[%d], max[%d]",
+                                       info[i].keyword, irange->min, irange->max);
 
-                               /* "mm_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
-                               /* mm_attrs_set_valid_type (attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_RANGE); */
                                mm_attrs_set_valid_range(attrs, info[i].attr_idx, irange->min, irange->max, irange->default_value);
-
                                ret = mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, irange->default_value);
                        }
 
@@ -1032,8 +1028,7 @@ int __mmcamcorder_set_info_to_attr(MMHandleType handle, _MMCamcorderInfoConverti
                                break; /* skip to set */
                        }
 
-                       MMCAM_LOG_VERBOSE("String - string[%s]", cString);
-
+                       MMCAM_LOG_DEBUG("[%s] String - string[%s]", info[i].keyword, cString);
                        ret = mm_attrs_set_string(attrs, info[i].attr_idx, cString, cString ? strlen(cString) : 0);
                        break;
                }
@@ -1045,21 +1040,17 @@ int __mmcamcorder_set_info_to_attr(MMHandleType handle, _MMCamcorderInfoConverti
                                break; /* skip to set, but not error */
 
                        if (pair_array && pair_array->count > 0) {
-                               /* "mm_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
-                               /* mm_attrs_set_valid_type(attrs, info[i].attr_idx, MM_ATTRS_VALID_TYPE_INT_ARRAY); */
                                mm_attrs_set_valid_array(attrs, info[i].attr_idx,
                                        pair_array->value[0],
                                        pair_array->count,
                                        pair_array->default_value[0]);
-                               /* "mm_attrs_set_valid_type" initializes spec value in attribute, so allocated memory could be missed */
-                               /* mm_attrs_set_valid_type(attrs, info[i].attr_idx_pair, MM_ATTRS_VALID_TYPE_INT_ARRAY); */
                                mm_attrs_set_valid_array(attrs, info[i].attr_idx_pair,
                                        pair_array->value[1],
                                        pair_array->count,
                                        pair_array->default_value[1]);
 
-                               MMCAM_LOG_VERBOSE("INT PAIR Array - default[%d,%d]",
-                                       pair_array->default_value[0], pair_array->default_value[1]);
+                               MMCAM_LOG_DEBUG("[%s] INT PAIR Array - default[%d,%d]",
+                                       info[i].keyword, pair_array->default_value[0], pair_array->default_value[1]);
 
                                mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx, pair_array->default_value[0]);
                                mm_attrs_set_int(MMF_CAMCORDER_ATTRS(hcamcorder), info[i].attr_idx_pair, pair_array->default_value[1]);