[Groonga-commit] groonga/groonga at a972c3c [master] Add support for multiline log message

Back to archive index
Kouhei Sutou null+****@clear*****
Fri May 10 10:04:05 JST 2019


Kouhei Sutou	2019-05-10 10:04:05 +0900 (Fri, 10 May 2019)

  Revision: a972c3cc0ee42f2d4390ae2a54297f1211b273e6
  https://github.com/groonga/groonga/commit/a972c3cc0ee42f2d4390ae2a54297f1211b273e6

  Message:
    Add support for multiline log message

  Modified files:
    lib/logger.c
    test/command/suite/select/filter/invalid/match/argument/column.expected

  Modified: lib/logger.c (+26 -2)
===================================================================
--- lib/logger.c    2019-05-09 19:17:01 +0900 (a413b0da8)
+++ lib/logger.c    2019-05-10 10:04:05 +0900 (9c5fd7afa)
@@ -558,8 +558,32 @@ grn_logger_putv(grn_ctx *ctx,
         lbuf_rest_size -= lbuf_size;
       }
     }
-    current_logger.log(ctx, level, tbuf, "", mbuf, lbuf,
-                       current_logger.user_data);
+
+    if (mbuf[0] == '\0') {
+      current_logger.log(ctx, level, tbuf, "", mbuf, lbuf,
+                         current_logger.user_data);
+    } else {
+      const char *mbuf_line_start = mbuf;
+      const char *mbuf_end = mbuf + strlen(mbuf);
+      int mbuf_char_length = 0;
+      for (char *mbuf_current = mbuf;
+           mbuf_current < mbuf_end;
+           mbuf_current += mbuf_char_length) {
+        mbuf_char_length = grn_charlen(ctx, mbuf_current, mbuf_end);
+        if (mbuf_char_length == 0) {
+          break;
+        } else if (mbuf_char_length == 1 && mbuf_current[0] == '\n') {
+          mbuf_current[0] = '\0';
+          current_logger.log(ctx, level, tbuf, "", mbuf_line_start, lbuf,
+                             current_logger.user_data);
+          mbuf_line_start = mbuf_current + 1;
+        }
+      }
+      if (mbuf_line_start < mbuf_end) {
+        current_logger.log(ctx, level, tbuf, "", mbuf_line_start, lbuf,
+                           current_logger.user_data);
+      }
+    }
   }
 }
 

  Modified: test/command/suite/select/filter/invalid/match/argument/column.expected (+9 -9)
===================================================================
--- test/command/suite/select/filter/invalid/match/argument/column.expected    2019-05-09 19:17:01 +0900 (d40e69dbd)
+++ test/command/suite/select/filter/invalid/match/argument/column.expected    2019-05-10 10:04:05 +0900 (5f1d3f338)
@@ -25,12 +25,12 @@ select Sites --filter "_key @ uri"
   ]
 ]
 #|e| invalid expression: can't use column as a value: <Sites.uri>: <#<expr
-  vars:{
-    $1:#<record:hash:Sites id:(no value)>
-  },
-  codes:{
-    0:<get_value n_args:1, flags:0, modify:2, value:#<accessor _key(Sites)>>,
-    1:<get_value n_args:1, flags:0, modify:0, value:#<column:var_size Sites.uri range:ShortText type:scalar compress:none>>,
-    2:<match n_args:2, flags:0, modify:0, value:(NULL)>
-  }
->>
+#|e|   vars:{
+#|e|     $1:#<record:hash:Sites id:(no value)>
+#|e|   },
+#|e|   codes:{
+#|e|     0:<get_value n_args:1, flags:0, modify:2, value:#<accessor _key(Sites)>>,
+#|e|     1:<get_value n_args:1, flags:0, modify:0, value:#<column:var_size Sites.uri range:ShortText type:scalar compress:none>>,
+#|e|     2:<match n_args:2, flags:0, modify:0, value:(NULL)>
+#|e|   }
+#|e| >>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190510/53959ab2/attachment-0001.html>


More information about the Groonga-commit mailing list
Back to archive index