int main(int argc, char **argv) { int exit_code = EXIT_SUCCESS; if (argc != 3) { fprintf(stderr, "Usage: %s DB_PATH RUBY_SCRIPT_PATH\n", argv[0]); return EXIT_FAILURE; } grn_default_logger_set_path(GRN_LOG_PATH); if (grn_init() != GRN_SUCCESS) { return EXIT_FAILURE; } { grn_ctx ctx; grn_ctx_init(&ctx, 0); exit_code = run(&ctx, argv[1], argv[2]); grn_ctx_fin(&ctx); } grn_fin(); return exit_code; }
/* * Sets the log path that is used by the default logger. If you're using * custom logger by {.register}, the log path isn't used. Because it * is for the default logger. * * If you specify nil as path, logging by the default logger is * disabled. * * @example Changes the log path for the default logger * Groonga::Logger.path = "/tmp/groonga.log" * * @example Disables log by the default logger * Groonga::Logger.path = nil * * @overload path=(path) * @param path [String or nil] The log path for the default logger. * If nil is specified, logging by the default logger is disabled. * @return void * * @since 3.0.1 */ static VALUE rb_grn_logger_s_set_path (VALUE klass, VALUE rb_path) { grn_bool need_reopen = GRN_FALSE; const char *old_path = NULL; const char *path = NULL; rb_path = rb_grn_check_convert_to_string(rb_path); if (!NIL_P(rb_path)) { path = StringValuePtr(rb_path); } old_path = grn_default_logger_get_path(); if (!rb_grn_equal_string(old_path, path)) { need_reopen = GRN_TRUE; } grn_default_logger_set_path(path); if (need_reopen) { rb_grn_logger_s_reopen_with_related_object(klass, rb_path); } return Qnil; }
static ngx_int_t ngx_http_groonga_init_process(ngx_cycle_t *cycle) { grn_rc rc; ngx_http_conf_ctx_t *http_conf; ngx_http_groonga_database_callback_data_t data; grn_thread_set_get_limit_func(ngx_http_groonga_get_thread_limit, NULL); #ifdef NGX_HTTP_GROONGA_LOG_PATH grn_default_logger_set_path(NGX_HTTP_GROONGA_LOG_PATH); #endif rc = grn_init(); if (rc != GRN_SUCCESS) { return NGX_ERROR; } grn_set_segv_handler(); rc = grn_ctx_init(context, GRN_NO_FLAGS); if (rc != GRN_SUCCESS) { return NGX_ERROR; } http_conf = (ngx_http_conf_ctx_t *)ngx_get_conf(cycle->conf_ctx, ngx_http_module); data.log = cycle->log; data.pool = cycle->pool; data.rc = NGX_OK; ngx_http_groonga_each_loc_conf(http_conf, ngx_http_groonga_open_database_callback, &data); return data.rc; }