Kouhei Sutou
null+****@clear*****
Sat May 30 17:12:29 JST 2015
Kouhei Sutou 2015-05-30 17:12:29 +0900 (Sat, 30 May 2015) New Revision: d30b2f9063500ab4439e545e1d168c3c9bee8da7 https://github.com/pgroonga/pgroonga/commit/d30b2f9063500ab4439e545e1d168c3c9bee8da7 Message: Use Groonga's default logger Log path is changed. It's incompatible change. Modified files: pgroonga.c pgroonga.h Modified: pgroonga.c (+12 -36) =================================================================== --- pgroonga.c 2015-05-30 15:26:37 +0900 (6b0844b) +++ pgroonga.c 2015-05-30 17:12:29 +0900 (8fc025c) @@ -156,6 +156,16 @@ static grn_obj bodyBuffer; static grn_obj footBuffer; static grn_obj inspectBuffer; +static void +PGrnSetLogPath(void) +{ + char path[MAXPGPATH]; + join_path_components(path, + GetDatabasePath(MyDatabaseId, DEFAULTTABLESPACE_OID), + PGrnLogBasename); + grn_default_logger_set_path(path); +} + static const char * PGrnInspect(grn_obj *object) { @@ -226,40 +236,6 @@ 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; @@ -391,6 +367,8 @@ PGrnInitializeOptions(void) void _PG_init(void) { + PGrnSetLogPath(); + if (grn_init() != GRN_SUCCESS) ereport(ERROR, (errcode(ERRCODE_SYSTEM_ERROR), @@ -400,8 +378,6 @@ _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); Modified: pgroonga.h (+1 -0) =================================================================== --- pgroonga.h 2015-05-30 15:26:37 +0900 (2e7a7cf) +++ pgroonga.h 2015-05-30 17:12:29 +0900 (0b7da96) @@ -28,6 +28,7 @@ #define PGrnQueryStrategyNumber 8 /* operator @@ (Groonga query) */ /* file and table names */ +#define PGrnLogBasename "pgroonga.log" #define PGrnDatabaseBasename "pgrn" #define PGrnSourcesTableNamePrefix "Sources" #define PGrnSourcesTableNameFormat PGrnSourcesTableNamePrefix "%u" -------------- next part -------------- HTML����������������������������...Download