#include "util.h"
#include "macro.h"
#include "strv.h"
+#include "log.h"
#define WHITESPACE " \t\n"
#define COMMENTS "#;\n"
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;
}
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;
}
}
if (!(e = strchr(b, '='))) {
- fprintf(stderr, "[%s:%u] Missing '='.\n", filename, line);
+ log_error("[%s:%u] Missing '='.", filename, line);
return -EBADMSG;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
#include "strv.h"
#include "conf-parser.h"
#include "load-fragment.h"
+#include "log.h"
static int config_parse_deps(
const char *filename,
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(
*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;
}
#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;
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;
}
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;
}
#include "hashmap.h"
#include "macro.h"
#include "strv.h"
+#include "log.h"
Manager* manager_new(void) {
Manager *m;
j->object_list = other->object_list;
}
-
/* Kill the other job */
other->subject_list = NULL;
other->object_list = NULL;
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;
}
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");