Code

Renamed error recording / logging functions.
[sysdb.git] / src / backend / puppet-storeconfigs.c
index 4c92c151770c53a34b44b147df793658c3343752..d55b76477d33bfbc2aadf7f3ad2ff938eebeb44f 100644 (file)
@@ -67,13 +67,13 @@ sdb_puppet_stcfg_get_hosts(sdb_dbi_client_t __attribute__((unused)) *client,
        status = sdb_store_host(&host);
 
        if (status < 0) {
        status = sdb_store_host(&host);
 
        if (status < 0) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
                                "store/update host '%s'.\n", host.host_name);
                free(host.host_name);
                return -1;
        }
        else if (! status)
                                "store/update host '%s'.\n", host.host_name);
                free(host.host_name);
                return -1;
        }
        else if (! status)
-               sdb_error_set(SDB_LOG_DEBUG, "puppet storeconfigs backend: "
+               sdb_log(SDB_LOG_DEBUG, "puppet storeconfigs backend: "
                                "Added/updated host '%s' (last update timestamp = "
                                "%"PRIscTIME").\n", host.host_name, host.host_last_update);
        free(host.host_name);
                                "Added/updated host '%s' (last update timestamp = "
                                "%"PRIscTIME").\n", host.host_name, host.host_last_update);
        free(host.host_name);
@@ -103,7 +103,7 @@ sdb_puppet_stcfg_get_attrs(sdb_dbi_client_t __attribute__((unused)) *client,
        status = sdb_store_attribute(&attr);
 
        if (status < 0) {
        status = sdb_store_attribute(&attr);
 
        if (status < 0) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
                                "store/update host attribute '%s' for host '%s'.\n",
                                attr.attr_name, attr.hostname);
                free(attr.hostname);
                                "store/update host attribute '%s' for host '%s'.\n",
                                attr.attr_name, attr.hostname);
                free(attr.hostname);
@@ -132,12 +132,12 @@ sdb_puppet_stcfg_init(sdb_object_t *user_data)
 
        client = SDB_OBJ_WRAPPER(user_data)->data;
        if (sdb_dbi_client_connect(client)) {
 
        client = SDB_OBJ_WRAPPER(user_data)->data;
        if (sdb_dbi_client_connect(client)) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                "Failed to connect to the storeconfigs DB.\n");
                return -1;
        }
 
                                "Failed to connect to the storeconfigs DB.\n");
                return -1;
        }
 
-       sdb_error_set(SDB_LOG_INFO, "puppet storeconfigs backend: Successfully "
+       sdb_log(SDB_LOG_INFO, "puppet storeconfigs backend: Successfully "
                        "connected to the storeconfigs DB.\n");
        return 0;
 } /* sdb_puppet_stcfg_init */
                        "connected to the storeconfigs DB.\n");
        return 0;
 } /* sdb_puppet_stcfg_init */
@@ -152,7 +152,7 @@ sdb_puppet_stcfg_collect(sdb_object_t *user_data)
 
        client = SDB_OBJ_WRAPPER(user_data)->data;
        if (sdb_dbi_client_check_conn(client)) {
 
        client = SDB_OBJ_WRAPPER(user_data)->data;
        if (sdb_dbi_client_check_conn(client)) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                "Connection to storeconfigs DB failed.\n");
                return -1;
        }
                                "Connection to storeconfigs DB failed.\n");
                return -1;
        }
@@ -160,7 +160,7 @@ sdb_puppet_stcfg_collect(sdb_object_t *user_data)
        if (sdb_dbi_exec_query(client, "SELECT name, updated_at FROM hosts;",
                                sdb_puppet_stcfg_get_hosts, NULL, /* #columns = */ 2,
                                /* col types = */ SDB_TYPE_STRING, SDB_TYPE_DATETIME)) {
        if (sdb_dbi_exec_query(client, "SELECT name, updated_at FROM hosts;",
                                sdb_puppet_stcfg_get_hosts, NULL, /* #columns = */ 2,
                                /* col types = */ SDB_TYPE_STRING, SDB_TYPE_DATETIME)) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
                                "retrieve hosts from the storeconfigs DB.\n");
                return -1;
        }
                                "retrieve hosts from the storeconfigs DB.\n");
                return -1;
        }
@@ -178,7 +178,7 @@ sdb_puppet_stcfg_collect(sdb_object_t *user_data)
                                sdb_puppet_stcfg_get_attrs, NULL, /* #columns = */ 4,
                                /* col types = */ SDB_TYPE_STRING, SDB_TYPE_STRING,
                                SDB_TYPE_STRING, SDB_TYPE_DATETIME)) {
                                sdb_puppet_stcfg_get_attrs, NULL, /* #columns = */ 4,
                                /* col types = */ SDB_TYPE_STRING, SDB_TYPE_STRING,
                                SDB_TYPE_STRING, SDB_TYPE_DATETIME)) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Failed to "
                                "retrieve host attributes from the storeconfigs DB.\n");
                return -1;
        }
                                "retrieve host attributes from the storeconfigs DB.\n");
                return -1;
        }
@@ -201,7 +201,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
        int i;
 
        if (oconfig_get_string(ci, &name)) {
        int i;
 
        if (oconfig_get_string(ci, &name)) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: Connection "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Connection "
                                "requires a single string argument\n"
                                "\tUsage: <Connection NAME>\n");
                return -1;
                                "requires a single string argument\n"
                                "\tUsage: <Connection NAME>\n");
                return -1;
@@ -215,7 +215,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
 
                if (! strcasecmp(child->key, "DBAdapter")) {
                        if (oconfig_get_string(child, &driver)) {
 
                if (! strcasecmp(child->key, "DBAdapter")) {
                        if (oconfig_get_string(child, &driver)) {
-                               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+                               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                                "DBAdapter requires a single string argument inside "
                                                "<Connection %s>\n\tUsage: DBAdapter NAME\n",
                                                name);
                                                "DBAdapter requires a single string argument inside "
                                                "<Connection %s>\n\tUsage: DBAdapter NAME\n",
                                                name);
@@ -224,7 +224,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
                }
                else if (! strcasecmp(child->key, "DBName")) {
                        if (oconfig_get_string(child, &database)) {
                }
                else if (! strcasecmp(child->key, "DBName")) {
                        if (oconfig_get_string(child, &database)) {
-                               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+                               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                                "DBName requires a single string argument inside "
                                                "<Connection %s>\n\tUsage: DBName NAME\n",
                                                name);
                                                "DBName requires a single string argument inside "
                                                "<Connection %s>\n\tUsage: DBName NAME\n",
                                                name);
@@ -251,7 +251,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
                        if ((child->values_num != 2)
                                        || (child->values[0].type != OCONFIG_TYPE_STRING)
                                        || (child->values[1].type != OCONFIG_TYPE_STRING)) {
                        if ((child->values_num != 2)
                                        || (child->values[0].type != OCONFIG_TYPE_STRING)
                                        || (child->values[1].type != OCONFIG_TYPE_STRING)) {
-                               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+                               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                                "DBIOption requires exactly two string arguments "
                                                "inside <Connection %s>\n"
                                                "\tUsage: DBIOption KEY VALUE\n", name);
                                                "DBIOption requires exactly two string arguments "
                                                "inside <Connection %s>\n"
                                                "\tUsage: DBIOption KEY VALUE\n", name);
@@ -263,14 +263,14 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
                        value = child->values[1].value.string;
                }
                else {
                        value = child->values[1].value.string;
                }
                else {
-                       sdb_error_set(SDB_LOG_WARNING, "puppet storeconfigs backend: "
+                       sdb_log(SDB_LOG_WARNING, "puppet storeconfigs backend: "
                                        "Ignoring unknown config option '%s' inside "
                                        "<Connection %s>.\n", child->key, name);
                        continue;
                }
 
                if (status) {
                                        "Ignoring unknown config option '%s' inside "
                                        "<Connection %s>.\n", child->key, name);
                        continue;
                }
 
                if (status) {
-                       sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: Option "
+                       sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: Option "
                                        "'%s' requires a single string argument inside "
                                        "<Connection %s>\n\tUsage: DBAdapter NAME\n",
                                        child->key, name);
                                        "'%s' requires a single string argument inside "
                                        "<Connection %s>\n\tUsage: DBAdapter NAME\n",
                                        child->key, name);
@@ -282,7 +282,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
                if (! options) {
                        if (! (options = sdb_dbi_options_create())) {
                                char errmsg[1024];
                if (! options) {
                        if (! (options = sdb_dbi_options_create())) {
                                char errmsg[1024];
-                               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+                               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                                "Failed to create DBI options object: %s\n",
                                                sdb_strerror(errno, errmsg, sizeof(errmsg)));
                                continue;
                                                "Failed to create DBI options object: %s\n",
                                                sdb_strerror(errno, errmsg, sizeof(errmsg)));
                                continue;
@@ -291,7 +291,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
 
                if (sdb_dbi_options_add(options, key, value)) {
                        char errmsg[1024];
 
                if (sdb_dbi_options_add(options, key, value)) {
                        char errmsg[1024];
-                       sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+                       sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                        "Failed to add option '%s': %s\n", key,
                                        sdb_strerror(errno, errmsg, sizeof(errmsg)));
                        continue;
                                        "Failed to add option '%s': %s\n", key,
                                        sdb_strerror(errno, errmsg, sizeof(errmsg)));
                        continue;
@@ -299,13 +299,13 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
        }
 
        if (! driver) {
        }
 
        if (! driver) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                "Connection '%s' " "missing the 'DBAdapter' option.\n",
                                name);
                return -1;
        }
        if (! database) {
                                "Connection '%s' " "missing the 'DBAdapter' option.\n",
                                name);
                return -1;
        }
        if (! database) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                "Connection '%s' missing the 'DBName' option.\n", name);
                return -1;
        }
                                "Connection '%s' missing the 'DBName' option.\n", name);
                return -1;
        }
@@ -316,7 +316,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
        client = sdb_dbi_client_create(driver, database);
        if (! client) {
                char errbuf[1024];
        client = sdb_dbi_client_create(driver, database);
        if (! client) {
                char errbuf[1024];
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                "Failed to create DBI client: %s\n",
                                sdb_strerror(errno, errbuf, sizeof(errbuf)));
                return -1;
                                "Failed to create DBI client: %s\n",
                                sdb_strerror(errno, errbuf, sizeof(errbuf)));
                return -1;
@@ -328,7 +328,7 @@ sdb_puppet_stcfg_config_conn(oconfig_item_t *ci)
                        (void (*)(void *))sdb_dbi_client_destroy);
        if (! user_data) {
                sdb_dbi_client_destroy(client);
                        (void (*)(void *))sdb_dbi_client_destroy);
        if (! user_data) {
                sdb_dbi_client_destroy(client);
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: "
                                "Failed to allocate sdb_object_t\n");
                return -1;
        }
                                "Failed to allocate sdb_object_t\n");
                return -1;
        }
@@ -353,7 +353,7 @@ sdb_puppet_stcfg_config(oconfig_item_t *ci)
                if (! strcasecmp(child->key, "Connection"))
                        sdb_puppet_stcfg_config_conn(child);
                else
                if (! strcasecmp(child->key, "Connection"))
                        sdb_puppet_stcfg_config_conn(child);
                else
-                       sdb_error_set(SDB_LOG_WARNING, "puppet storeconfigs backend: "
+                       sdb_log(SDB_LOG_WARNING, "puppet storeconfigs backend: "
                                        "Ignoring unknown config option '%s'.\n", child->key);
        }
        return 0;
                                        "Ignoring unknown config option '%s'.\n", child->key);
        }
        return 0;
@@ -372,7 +372,7 @@ sdb_module_init(sdb_plugin_info_t *info)
        sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
 
        if (dbi_initialize(/* driver dir = */ NULL) < 0) {
        sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION);
 
        if (dbi_initialize(/* driver dir = */ NULL) < 0) {
-               sdb_error_set(SDB_LOG_ERR, "puppet storeconfigs backend: failed to "
+               sdb_log(SDB_LOG_ERR, "puppet storeconfigs backend: failed to "
                                "initialize DBI; possibly you don't have any drivers "
                                "installed.\n");
                return -1;
                                "initialize DBI; possibly you don't have any drivers "
                                "installed.\n");
                return -1;