chiark / gitweb /
Use CLOCK_MONOTONIC for all our timing needs, when possible
[secnet.git] / log.c
diff --git a/log.c b/log.c
index f937d2ec35d4500294d568d43da2e4258ed3512e..aca1b9b8e415ea6a86fc89e20a68144cbcd4467c 100644 (file)
--- a/log.c
+++ b/log.c
@@ -162,6 +162,18 @@ void cfgfatal_maybefile(FILE *maybe_f, struct cloc loc, cstring_t facility,
     va_end(args);
 }    
 
+void cfgfatal_cl_type(struct cloc loc, const char *facility,
+                     closure_t *cl, uint32_t exp_type, const char *name)
+{
+    char expbuf[10], gotbuf[10];
+    assert(cl->type != exp_type);
+    const char *exp = closure_type_name(exp_type, expbuf);
+    const char *got = closure_type_name(cl->type, gotbuf);
+    cfgfatal(loc,facility,
+            "\"%s\" is the wrong type of closure (expected %s, got %s)\n",
+            name, exp, got);
+}
+
 void cfgfatal(struct cloc loc, cstring_t facility, const char *message, ...)
 {
     va_list args;
@@ -659,9 +671,14 @@ void log_from_fd(int fd, cstring_t prefix, struct log_if *log)
 }
 
 static struct logfile startup_log;
+void log_early_setlevel(void)
+{
+    startup_log.level=message_level;
+}
 void log_early_init(void)
 {
     logfile_file_init(&startup_log,stderr,"startup");
+    log_early_setlevel();
     system_log=&startup_log.ops;;
 }