exit(-1);
}
+static int is_enable_sdbd_log()
+{
+ return (!strncmp(g_capabilities.log_enable, SDBD_CAP_RET_ENABLED, strlen(SDBD_CAP_RET_ENABLED)));
+}
+
int sdb_trace_mask;
/* read a comma/space/colum/semi-column separated list of tags
{ NULL, 0 }
};
- if (p == NULL)
+ if (p == NULL) {
+ if (is_enable_sdbd_log())
+ p = "all";
+ else
return;
+ }
/* use a comma/column/semi-colum/space separated list */
while (*p) {
}
#if !SDB_HOST
+
void start_device_log(void)
{
int fd;
- char path[PATH_MAX];
+ char path[PATH_MAX] = {0, };
+ char path_folder[PATH_MAX] = {0, };
+ char path_file[PATH_MAX] = {0, };
struct tm now;
time_t t;
// char value[PROPERTY_VALUE_MAX];
- const char* p = getenv("SDB_TRACE");
+ const char* p_trace = getenv("SDB_TRACE");
+ const char* p_path = getenv("SDBD_LOG_PATH");
// read the trace mask from persistent property persist.sdb.trace_mask
// give up if the property is not set or cannot be parsed
#if 0 /* tizen specific */
return;
#endif
- if (p == NULL) {
+ if ((p_trace == NULL ) && !is_enable_sdbd_log()) {
return;
}
+
+ if (p_path)
+ snprintf(path_folder, sizeof(path_folder), "%s", p_path);
+ else if (g_capabilities.log_path[0] != '\0')
+ snprintf(path_folder, sizeof(path_folder), "%s", g_capabilities.log_path);
+ else
+ return;
+
tzset();
time(&t);
localtime_r(&t, &now);
- strftime(path, sizeof(path),
- "/tmp/sdbd-%Y-%m-%d-%H-%M-%S.txt",
- &now);
- fd = unix_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0640);
+
+ strftime(path_file, sizeof(path_file),
+ "sdbd-%Y-%m-%d-%H-%M-%S.txt",
+ &now);
+
+ snprintf(path, sizeof(path), "%s/%s", path_folder, path_file);
+
+ fd = unix_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (fd < 0) {
return;
}
} else if (SDBD_CMP_CAP(in_buf, PRODUCT_VER)) {
snprintf(out.data, out.len, "%s", UNKNOWN);
ret = SDBD_PLUGIN_RET_SUCCESS;
+ } else if (SDBD_CMP_CAP(in_buf, LOG_ENABLE)) {
+ snprintf(out.data, out.len, "%s", SDBD_CAP_RET_DISABLED);
+ ret = SDBD_PLUGIN_RET_SUCCESS;
+ } else if (SDBD_CMP_CAP(in_buf, LOG_PATH)) {
+ snprintf(out.data, out.len, "%s", "/tmp");
+ ret = SDBD_PLUGIN_RET_SUCCESS;
}
return ret;
snprintf(g_capabilities.sdbd_plugin_version, sizeof(g_capabilities.sdbd_plugin_version),
"%s", UNKNOWN);
}
+
+ // sdbd log enable
+ if(!request_plugin_cmd(SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_ENABLE,
+ g_capabilities.log_enable,
+ sizeof(g_capabilities.log_enable))) {
+ D("failed to request. (%s:%s) \n", SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_ENABLE);
+ snprintf(g_capabilities.log_enable, sizeof(g_capabilities.log_enable),
+ "%s", DISABLED);
+ }
+
+ // sdbd log path
+ if(!request_plugin_cmd(SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_PATH,
+ g_capabilities.log_path,
+ sizeof(g_capabilities.log_path))) {
+ D("failed to request. (%s:%s) \n", SDBD_CMD_PLUGIN_CAP, SDBD_CAP_TYPE_LOG_PATH);
+ snprintf(g_capabilities.log_path, sizeof(g_capabilities.log_path),
+ "%s", UNKNOWN);
+ }
}
static int is_support_usbproto()
load_sdbd_plugin();
init_capabilities();
+ sdb_trace_init();
+ start_device_log();
+
init_drop_privileges();
init_sdk_requirements();
if (!request_plugin_verification(SDBD_CMD_VERIFY_LAUNCH, NULL)) {
int main(int argc, char **argv)
{
- sdb_trace_init(); /* tizen specific */
#if SDB_HOST
sdb_sysdeps_init();
sdb_trace_init();
fatal("daemonize() failed: errno:%d", errno);
#endif
- start_device_log();
D("Handling main()\n");
//sdbd will never die on emulator!