summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--conf-parser.c19
-rw-r--r--load-fragment.c14
-rw-r--r--main.c15
-rw-r--r--manager.c3
-rw-r--r--test-engine.c2
5 files changed, 34 insertions, 19 deletions
diff --git a/conf-parser.c b/conf-parser.c
index 3a7da7960c..2ea6911257 100644
--- a/conf-parser.c
+++ b/conf-parser.c
@@ -10,6 +10,7 @@
#include "util.h"
#include "macro.h"
#include "strv.h"
+#include "log.h"
#define WHITESPACE " \t\n"
#define COMMENTS "#;\n"
@@ -44,7 +45,7 @@ static int next_assignment(
return t->parse(filename, line, section, lvalue, rvalue, t->data, userdata);
}
- fprintf(stderr, "[%s:%u] Unknown lvalue '%s' in section '%s'.\n", filename, line, lvalue, strna(section));
+ log_error("[%s:%u] Unknown lvalue '%s' in section '%s'.", filename, line, lvalue, strna(section));
return -EBADMSG;
}
@@ -122,7 +123,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
assert(k > 0);
if (b[k-1] != ']') {
- fprintf(stderr, "[%s:%u] Invalid section header.\n", filename, line);
+ log_error("[%s:%u] Invalid section header.", filename, line);
return -EBADMSG;
}
@@ -151,7 +152,7 @@ static int parse_line(const char *filename, unsigned line, char **section, const
}
if (!(e = strchr(b, '='))) {
- fprintf(stderr, "[%s:%u] Missing '='.\n", filename, line);
+ log_error("[%s:%u] Missing '='.", filename, line);
return -EBADMSG;
}
@@ -173,7 +174,7 @@ int config_parse(const char *filename, const char* const * sections, const Confi
if (!(f = fopen(filename, "re"))) {
r = -errno;
- fprintf(stderr, "Failed to open configuration file '%s': %s\n", filename, strerror(-r));
+ log_error("Failed to open configuration file '%s': %s", filename, strerror(-r));
goto finish;
}
@@ -185,7 +186,7 @@ int config_parse(const char *filename, const char* const * sections, const Confi
break;
r = -errno;
- fprintf(stderr, "Failed to read configuration file '%s': %s\n", filename, strerror(-r));
+ log_error("Failed to read configuration file '%s': %s", filename, strerror(-r));
goto finish;
}
@@ -222,7 +223,7 @@ int config_parse_int(
assert(data);
if ((r = safe_atoi(rvalue, i)) < 0) {
- fprintf(stderr, "[%s:%u] Failed to parse numeric value: %s\n", filename, line, rvalue);
+ log_error("[%s:%u] Failed to parse numeric value: %s", filename, line, rvalue);
return r;
}
@@ -247,7 +248,7 @@ int config_parse_unsigned(
assert(data);
if ((r = safe_atou(rvalue, u)) < 0) {
- fprintf(stderr, "[%s:%u] Failed to parse numeric value: %s\n", filename, line, rvalue);
+ log_error("[%s:%u] Failed to parse numeric value: %s", filename, line, rvalue);
return r;
}
@@ -273,7 +274,7 @@ int config_parse_size(
assert(data);
if ((r = safe_atou(rvalue, &u)) < 0) {
- fprintf(stderr, "[%s:%u] Failed to parse numeric value: %s\n", filename, line, rvalue);
+ log_error("[%s:%u] Failed to parse numeric value: %s", filename, line, rvalue);
return r;
}
@@ -299,7 +300,7 @@ int config_parse_bool(
assert(data);
if ((k = parse_boolean(rvalue)) < 0) {
- fprintf(stderr, "[%s:%u] Failed to parse boolean value: %s\n", filename, line, rvalue);
+ log_error("[%s:%u] Failed to parse boolean value: %s", filename, line, rvalue);
return k;
}
diff --git a/load-fragment.c b/load-fragment.c
index ed96865248..ed046d0356 100644
--- a/load-fragment.c
+++ b/load-fragment.c
@@ -8,6 +8,7 @@
#include "strv.h"
#include "conf-parser.h"
#include "load-fragment.h"
+#include "log.h"
static int config_parse_deps(
const char *filename,
@@ -130,12 +131,19 @@ static int config_parse_listen(
void *data,
void *userdata) {
+ int r;
+
assert(filename);
assert(lvalue);
assert(rvalue);
assert(data);
- return address_parse(data, rvalue);
+ if ((r = address_parse(data, rvalue)) < 0) {
+ log_error("[%s:%u] Failed to parse address value: %s", filename, line, rvalue);
+ return r;
+ }
+
+ return 0;
}
static int config_parse_type(
@@ -158,8 +166,10 @@ static int config_parse_type(
*type = SOCK_STREAM;
else if (streq(rvalue, "dgram"))
*type = SOCK_DGRAM;
- else
+ else {
+ log_error("[%s:%u] Failed to parse socket type value: %s", filename, line, rvalue);
return -EINVAL;
+ }
return 0;
}
diff --git a/main.c b/main.c
index f42710b64b..b22a639396 100644
--- a/main.c
+++ b/main.c
@@ -3,8 +3,10 @@
#include <stdio.h>
#include <errno.h>
#include <string.h>
+#include <unistd.h>
#include "manager.h"
+#include "log.h"
int main(int argc, char *argv[]) {
Manager *m = NULL;
@@ -12,24 +14,25 @@ int main(int argc, char *argv[]) {
Job *job = NULL;
int r, retval = 1;
+ assert_se(chdir("test1") == 0);
+
if (!(m = manager_new()) < 0) {
- fprintf(stderr, "Failed to allocate manager object: %s\n", strerror(ENOMEM));
+ log_error("Failed to allocate manager object: %s", strerror(ENOMEM));
goto finish;
}
-
if ((r = manager_load_name(m, "default.milestone", &milestone)) < 0) {
- fprintf(stderr, "Failed to load default milestone: %s\n", strerror(-r));
+ log_error("Failed to load default milestone: %s", strerror(-r));
goto finish;
}
if ((r = manager_load_name(m, "syslog.socket", &syslog)) < 0) {
- fprintf(stderr, "Failed to load syslog socket: %s\n", strerror(-r));
+ log_error("Failed to load syslog socket: %s", strerror(-r));
goto finish;
}
if ((r = manager_add_job(m, JOB_START, milestone, JOB_REPLACE, false, &job)) < 0) {
- fprintf(stderr, "Failed to start default milestone: %s\n", strerror(-r));
+ log_error("Failed to start default milestone: %s", strerror(-r));
goto finish;
}
@@ -40,7 +43,7 @@ int main(int argc, char *argv[]) {
manager_dump_jobs(m, stdout, "\t");
if ((r = manager_add_job(m, JOB_STOP, syslog, JOB_REPLACE, false, &job)) < 0) {
- fprintf(stderr, "Failed to start default milestone: %s\n", strerror(-r));
+ log_error("Failed to start default milestone: %s", strerror(-r));
goto finish;
}
diff --git a/manager.c b/manager.c
index a104e2f401..456eb8db1c 100644
--- a/manager.c
+++ b/manager.c
@@ -8,6 +8,7 @@
#include "hashmap.h"
#include "macro.h"
#include "strv.h"
+#include "log.h"
Manager* manager_new(void) {
Manager *m;
@@ -166,7 +167,6 @@ static void transaction_merge_and_delete_job(Manager *m, Job *j, Job *other, Job
j->object_list = other->object_list;
}
-
/* Kill the other job */
other->subject_list = NULL;
other->object_list = NULL;
@@ -221,6 +221,7 @@ static int transaction_verify_order_one(Manager *m, Job *j, Job *from, unsigned
for (k = from; k; k = (k->generation == generation ? k->marker : NULL)) {
if (!k->matters_to_anchor) {
+ log_debug("Breaking order cycle by deleting job %s", name_id(k->name));
manager_transaction_delete_job(m, k);
return -EAGAIN;
}
diff --git a/test-engine.c b/test-engine.c
index 61882a960f..15ce70f1ac 100644
--- a/test-engine.c
+++ b/test-engine.c
@@ -36,7 +36,7 @@ int main(int argc, char *argv[]) {
assert_se(manager_add_job(m, JOB_START, d, JOB_REPLACE, false, &j) == -ELOOP);
manager_dump_jobs(m, stdout, "\t");
- printf("Test2: (Cyclic Order, Fixable)\n");
+ printf("Test3: (Cyclic Order, Fixable)\n");
assert_se(manager_add_job(m, JOB_START, e, JOB_REPLACE, false, &j) == 0);
manager_dump_jobs(m, stdout, "\t");