chiark / gitweb /
log.h: new log_oom() -> int -ENOMEM, use it
[elogind.git] / src / shared / logs-show.c
index af9bcbd0f7e25ef0c2a70088ae7f70bb18d631ef..edb5a9cafb74dacfab17f84b6d5d62e83ca7b7de 100644 (file)
@@ -52,10 +52,8 @@ static int parse_field(const void *data, size_t length, const char *field, char
         buf = malloc(nl+1);
         memcpy(buf, (const char*) data + fl, nl);
         ((char*)buf)[nl] = 0;
-        if (!buf) {
-                log_error("Out of memory");
-                return -ENOMEM;
-        }
+        if (!buf)
+                return log_oom();
 
         free(*target);
         *target = buf;
@@ -225,9 +223,10 @@ static int output_short(sd_journal *j, unsigned line, unsigned n_columns,
         else if (!utf8_is_printable_n(message, message_len)) {
                 char bytes[FORMAT_BYTES_MAX];
                 printf(": [%s blob data]\n", format_bytes(bytes, sizeof(bytes), message_len));
-        } else if (message_len + n < n_columns)
+        } else if ((flags & OUTPUT_FULL_WIDTH) ||
+                   (message_len + n < n_columns))
                 printf(": %.*s\n", (int) message_len, message);
-        else if (n < n_columns) {
+        else if (n < n_columns && n_columns - n - 2 >= 3) {
                 char *e;
 
                 e = ellipsize_mem(message, message_len, n_columns - n - 2, 90);
@@ -553,15 +552,14 @@ int show_journal_by_unit(
                 unsigned n_columns,
                 usec_t not_before,
                 unsigned how_many,
-                bool show_all,
-                bool follow,
-                bool warn_cutoff) {
+                OutputFlags flags) {
 
         char *m = NULL;
         sd_journal *j = NULL;
         int r;
         unsigned line = 0;
         bool need_seek = false;
+        int warn_cutoff = flags & OUTPUT_WARN_CUTOFF;
 
         assert(mode >= 0);
         assert(mode < _OUTPUT_MODE_MAX);
@@ -633,8 +631,7 @@ int show_journal_by_unit(
 
                         line ++;
 
-                        r = output_journal(j, mode, line, n_columns,
-                                           show_all ? OUTPUT_SHOW_ALL : 0);
+                        r = output_journal(j, mode, line, n_columns, flags);
                         if (r < 0)
                                 goto finish;
                 }
@@ -659,7 +656,7 @@ int show_journal_by_unit(
                         warn_cutoff = false;
                 }
 
-                if (!follow)
+                if (!(flags & OUTPUT_FOLLOW))
                         break;
 
                 r = sd_journal_wait(j, (usec_t) -1);