summaryrefslogtreecommitdiff
path: root/common/config.c
diff options
context:
space:
mode:
authorjusung son <jusung07.son@samsung.com>2018-06-05 13:21:33 +0900
committerjusung son <jusung07.son@samsung.com>2018-06-07 10:51:14 +0900
commitbc2a82351a160e6f7c3353fed5a00ffb9493c95d (patch)
tree45d2bb15b8d0a33b44073ccd50aaa9eb374603bc /common/config.c
parent030c6353c4026d730402399e7bf1916aee70a047 (diff)
downloadbuxton2-bc2a82351a160e6f7c3353fed5a00ffb9493c95d.tar.gz
buxton2-bc2a82351a160e6f7c3353fed5a00ffb9493c95d.tar.bz2
buxton2-bc2a82351a160e6f7c3353fed5a00ffb9493c95d.zip
Add file log
Change-Id: Ieb3b8b76c1f88793081fd2111692863e1a744312 Signed-off-by: jusung son <jusung07.son@samsung.com>
Diffstat (limited to 'common/config.c')
-rw-r--r--common/config.c67
1 files changed, 66 insertions, 1 deletions
diff --git a/common/config.c b/common/config.c
index db144d7..84bb6e8 100644
--- a/common/config.c
+++ b/common/config.c
@@ -38,6 +38,10 @@
#define K_B_DB "persistent"
#define K_B_MEM "volatile"
+#define G_LOG_CONF "log-config"
+#define K_LOG_ON "OnOff"
+#define K_LOG_MAX "MaxLine"
+
static GHashTable *layers;
static void free_layer(struct layer *layer)
@@ -230,6 +234,65 @@ static void add_layers(GKeyFile *kf, GList *backends)
g_free(lays);
}
+static void load_log_conf(GKeyFile *kf, bool *log_on, int *max_line)
+{
+ GError *err = NULL;
+ gchar *buf = NULL;
+ assert(kf);
+
+ bool onoff;
+ int max = 0;
+
+ /* 'OnOff' */
+ buf = g_key_file_get_string(kf, G_LOG_CONF, K_LOG_ON, &err);
+ if (!buf) {
+ bxt_err("get_string failed :Group '%s', Key '%s' : %s",
+ G_LOG_CONF, K_LOG_ON, err ? err->message : "");
+ goto out;
+ }
+ if (strcasecmp(buf, "ON") == 0) {
+ onoff = true;
+ } else if (strcasecmp(buf, "OFF") == 0) {
+ onoff = false;
+ } else {
+ bxt_err("get_string failed : Group '%s', Key '%s' : '%s'(len:%d)",
+ G_LOG_CONF, K_LOG_ON, buf, strlen(buf));
+ goto out;
+ }
+
+ if (onoff) {
+ g_free(buf);
+ buf = NULL;
+
+ /* max line */
+ buf = g_key_file_get_string(kf, G_LOG_CONF, K_LOG_MAX, &err);
+ if (!buf) {
+ bxt_err("get_string failed : Group '%s', Key '%s' : '%s'",
+ G_LOG_CONF, K_LOG_MAX, err ? err->message : "");
+ goto out;
+ }
+
+ max = atoi(buf);
+ if (max <= 0) {
+ bxt_err("atoi failed : Group '%s', Key '%s' : '%s'",
+ G_LOG_CONF, K_LOG_MAX, buf);
+ goto out;
+ }
+ }
+
+ *log_on = onoff;
+ *max_line = max;
+ bxt_err("log config log on : %s , max line %d", onoff ? "True" : "False", max);
+
+out:
+ if (err)
+ g_clear_error(&err);
+ if (buf)
+ g_free(buf);
+
+ g_key_file_remove_group(kf, G_LOG_CONF, NULL);
+}
+
const struct layer *conf_get_layer(const char *name)
{
const struct layer *layer;
@@ -273,7 +336,7 @@ void conf_exit(void)
layers = NULL;
}
-int conf_init(const char *confpath, GList *backends)
+int conf_init(const char *confpath, GList *backends, bool *log_on, int *max_line)
{
GKeyFile *kf;
@@ -297,6 +360,8 @@ int conf_init(const char *confpath, GList *backends)
return -1;
}
+ load_log_conf(kf, log_on, max_line);
+
add_layers(kf, backends);
g_key_file_free(kf);