chiark / gitweb /
log: don't reopen /dev/console each time we call log_open()
[elogind.git] / src / shared / log.c
index 2531e0da0376cbba486e12fa243f73a70103b4f6..85ed6ecb67fef53f80a307c51ff7f845fa8ebdf9 100644 (file)
@@ -272,8 +272,6 @@ int log_open(void) {
         log_close_journal();
         log_close_syslog();
 
-        /* Get the real /dev/console if we are PID=1, hence reopen */
-        log_close_console();
         return log_open_console();
 }
 
@@ -690,6 +688,9 @@ int log_meta_object(
 static void log_assert(int level, const char *text, const char *file, int line, const char *func, const char *format) {
         static char buffer[LINE_MAX];
 
+        if (_likely_(LOG_PRI(level) > log_max_level))
+                return;
+
         snprintf(buffer, sizeof(buffer), format, text, file, line, func);
 
         char_array_0(buffer);
@@ -699,17 +700,18 @@ static void log_assert(int level, const char *text, const char *file, int line,
 }
 #pragma GCC diagnostic pop
 
-_noreturn_ void log_assert_failed(const char *text, const char *file, int line, const char *func) {
+noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) {
         log_assert(LOG_CRIT, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Aborting.");
         abort();
 }
 
-_noreturn_ void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) {
+noreturn void log_assert_failed_unreachable(const char *text, const char *file, int line, const char *func) {
         log_assert(LOG_CRIT, text, file, line, func, "Code should not be reached '%s' at %s:%u, function %s(). Aborting.");
         abort();
 }
 
 void log_assert_failed_return(const char *text, const char *file, int line, const char *func) {
+        PROTECT_ERRNO;
         log_assert(LOG_DEBUG, text, file, line, func, "Assertion '%s' failed at %s:%u, function %s(). Ignoring.");
 }