[Groonga-commit] pgroonga/pgroonga at 334266f [master] Support logging message from Groonga

Back to archive index

Kouhei Sutou null+****@clear*****
Sat May 23 16:23:09 JST 2015


Kouhei Sutou	2015-05-23 16:23:09 +0900 (Sat, 23 May 2015)

  New Revision: 334266f7e6a6959168183c0e94907c596b9ffcb2
  https://github.com/pgroonga/pgroonga/commit/334266f7e6a6959168183c0e94907c596b9ffcb2

  Message:
    Support logging message from Groonga

  Modified files:
    pgroonga.c

  Modified: pgroonga.c (+33 -0)
===================================================================
--- pgroonga.c    2015-05-11 09:49:00 +0900 (828578e)
+++ pgroonga.c    2015-05-23 16:23:09 +0900 (747e461)
@@ -203,6 +203,37 @@ PGrnEnsureDatabase(void)
 }
 
 static void
+PGrnLoggerLog(grn_ctx *ctx,
+			  grn_log_level level,
+			  const char *timestamp,
+			  const char *title,
+			  const char *message,
+			  const char *location,
+			  void *userData)
+{
+	const char levelTags[] = " EACewnid-";
+
+	if (location && *location) {
+		ereport(LOG,
+				(errmsg("pgroonga: %s|%c|%s %s %s",
+						timestamp, levelTags[level], title, message, location)));
+	} else {
+		ereport(LOG,
+				(errmsg("pgroonga: %s|%c|%s %s",
+						timestamp, levelTags[level], title, message)));
+	}
+}
+
+static grn_logger PGrnLogger = {
+	GRN_LOG_DEFAULT_LEVEL,
+	GRN_LOG_TIME | GRN_LOG_MESSAGE,
+	NULL,
+	PGrnLoggerLog,
+	NULL,
+	NULL
+};
+
+static void
 PGrnOnProcExit(int code, Datum arg)
 {
 	grn_obj *db;
@@ -343,6 +374,8 @@ _PG_init(void)
 				(errcode(ERRCODE_SYSTEM_ERROR),
 				 errmsg("pgroonga: failed to initialize Groonga context")));
 
+	grn_logger_set(ctx, &PGrnLogger);
+
 	on_proc_exit(PGrnOnProcExit, 0);
 
 	GRN_VOID_INIT(&buffer);
-------------- next part --------------
HTML����������������������������...
Download 



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