[Groonga-commit] pgroonga/pgroonga at 13564d7 [master] Add pgroonga.query_log_path

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Nov 29 00:59:23 JST 2016


Kouhei Sutou	2016-11-29 00:59:23 +0900 (Tue, 29 Nov 2016)

  New Revision: 13564d7a15be042c91cefba9a4aff364727fb2fb
  https://github.com/pgroonga/pgroonga/commit/13564d7a15be042c91cefba9a4aff364727fb2fb

  Message:
    Add pgroonga.query_log_path

  Added files:
    expected/variable/query-log-path/valid.out
    sql/variable/query-log-path/valid.sql
  Modified files:
    src/pgrn_variables.c
    src/pgroonga.h

  Added: expected/variable/query-log-path/valid.out (+27 -0) 100644
===================================================================
--- /dev/null
+++ expected/variable/query-log-path/valid.out    2016-11-29 00:59:23 +0900 (1599091)
@@ -0,0 +1,27 @@
+-- To load PGroonga
+SELECT pgroonga.command('status')::json->0->0;
+ ?column? 
+----------
+ 0
+(1 row)
+
+SHOW pgroonga.query_log_path;
+ pgroonga.query_log_path 
+-------------------------
+ none
+(1 row)
+
+SET pgroonga.query_log_path = 'pgroonga.query.log';
+SHOW pgroonga.query_log_path;
+ pgroonga.query_log_path 
+-------------------------
+ pgroonga.query.log
+(1 row)
+
+SET pgroonga.query_log_path = default;
+SHOW pgroonga.query_log_path;
+ pgroonga.query_log_path 
+-------------------------
+ none
+(1 row)
+

  Added: sql/variable/query-log-path/valid.sql (+8 -0) 100644
===================================================================
--- /dev/null
+++ sql/variable/query-log-path/valid.sql    2016-11-29 00:59:23 +0900 (001bcd5)
@@ -0,0 +1,8 @@
+-- To load PGroonga
+SELECT pgroonga.command('status')::json->0->0;
+
+SHOW pgroonga.query_log_path;
+SET pgroonga.query_log_path = 'pgroonga.query.log';
+SHOW pgroonga.query_log_path;
+SET pgroonga.query_log_path = default;
+SHOW pgroonga.query_log_path;

  Modified: src/pgrn_variables.c (+50 -0)
===================================================================
--- src/pgrn_variables.c    2016-11-24 00:16:51 +0900 (096be64)
+++ src/pgrn_variables.c    2016-11-29 00:59:23 +0900 (a61a045)
@@ -46,7 +46,10 @@ static struct config_enum_entry PGrnLogLevelEntries[] = {
 };
 #endif
 
+static char *PGrnQueryLogPath;
+
 static int PGrnLockTimeout;
+
 static bool PGrnEnableWAL;
 
 #ifdef PGRN_SUPPORT_ENUM_VARIABLE
@@ -142,6 +145,39 @@ PGrnLogLevelAssign(int new_value, void *extra)
 #endif
 
 static void
+PGrnQueryLogPathAssignRaw(const char *new_value)
+{
+	if (!new_value)
+	{
+		new_value = PGrnQueryLogPathDefault;
+	}
+
+	if (PGrnIsNoneValue(new_value))
+	{
+		grn_default_query_logger_set_path(NULL);
+	}
+	else
+	{
+		grn_default_query_logger_set_path(new_value);
+	}
+}
+
+#ifdef PGRN_IS_GREENPLUM
+static const char *
+PGrnQueryLogPathAssign(const char *new_value, bool doit, GucSource source)
+{
+	PGrnQueryLogPathAssignRaw(new_value);
+	return new_value;
+}
+#else
+static void
+PGrnQueryLogPathAssign(const char *new_value, void *extra)
+{
+	PGrnQueryLogPathAssignRaw(new_value);
+}
+#endif
+
+static void
 PGrnLockTimeoutAssignRaw(int new_value)
 {
 	grn_set_lock_timeout(new_value);
@@ -224,6 +260,20 @@ PGrnInitializeVariables(void)
 							 NULL);
 #endif
 
+	PGrnDefineCustomStringVariable("pgroonga.query_log_path",
+								   "Query log path for PGroonga.",
+								   "Path must be a relative path "
+								   "from \"${PG_DATA}/\" or absolute path. "
+								   "Use \"none\" to disable file output. "
+								   "The default is disabled.",
+								   &PGrnQueryLogPath,
+								   PGrnQueryLogPathDefault,
+								   PGC_USERSET,
+								   0,
+								   NULL,
+								   PGrnQueryLogPathAssign,
+								   NULL);
+
 	PGrnDefineCustomIntVariable("pgroonga.lock_timeout",
 								"Try pgroonga.lock_timeout times "
 								"at 1 msec intervals to "

  Modified: src/pgroonga.h (+1 -0)
===================================================================
--- src/pgroonga.h    2016-11-24 00:16:51 +0900 (ad33445)
+++ src/pgroonga.h    2016-11-29 00:59:23 +0900 (9edeac4)
@@ -39,6 +39,7 @@
 
 /* file and table names */
 #define PGrnLogBasename					"pgroonga.log"
+#define PGrnQueryLogPathDefault			"none"
 #define PGrnDatabaseBasename			"pgrn"
 #define PGrnSourcesTableNamePrefix		"Sources"
 #define PGrnSourcesTableNamePrefixLength	(sizeof(PGrnSourcesTableNamePrefix) - 1)
-------------- next part --------------
HTML����������������������������...
Download 



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