diff --git a/log_manager/log_manager.cc b/log_manager/log_manager.cc index cf3653f90..f73d02714 100644 --- a/log_manager/log_manager.cc +++ b/log_manager/log_manager.cc @@ -439,7 +439,7 @@ return_succ: * @return true if succeed, otherwise false * */ -bool skygw_logmanager_init(const char* ident, const char* logdir, log_target_t target) +bool mxs_log_init(const char* ident, const char* logdir, log_target_t target) { bool succ = false; @@ -504,22 +504,13 @@ static void logmanager_done_nomutex(void) lm = NULL; } - -/** - * This function is provided for atexit() system function. - */ -void skygw_logmanager_exit(void) -{ - skygw_logmanager_done(); -} - /** * End execution of log manager * * Stops file writing thread, releases filewriter, and logfiles. * */ -void skygw_logmanager_done(void) +void mxs_log_finish(void) { acquire_lock(&lmlock); diff --git a/log_manager/log_manager.h b/log_manager/log_manager.h index be52d7675..539df718f 100644 --- a/log_manager/log_manager.h +++ b/log_manager/log_manager.h @@ -138,6 +138,9 @@ extern int lm_enabled_logfiles_bitmask; extern ssize_t log_ses_count[]; extern __thread log_info_t tls_log_info; +bool mxs_log_init(const char* ident, const char* logdir, log_target_t target); +void mxs_log_finish(void); + int mxs_log_flush(); int mxs_log_rotate(); int mxs_log_enable_priority(int priority); @@ -147,16 +150,9 @@ int mxs_log_message(int priority, const char* file, int line, const char* function, const char* format, ...); -bool skygw_logmanager_init(const char* ident, - const char* logdir, - log_target_t target); -void skygw_logmanager_done(void); -void skygw_logmanager_exit(void); - /** * free private write buffer list */ -void skygw_log_done(void); int skygw_log_flush(logfile_id_t id); void skygw_log_sync_all(void); int skygw_log_enable(logfile_id_t id); diff --git a/log_manager/test/testlog.c b/log_manager/test/testlog.c index fc9c65255..c6f6320f0 100644 --- a/log_manager/test/testlog.c +++ b/log_manager/test/testlog.c @@ -113,14 +113,14 @@ int main(int argc, char* argv[]) err = 1; goto return_err; } - i = atexit(skygw_logmanager_exit); + i = atexit(mxs_log_finish); if (i != 0) { fprintf(stderr, "Couldn't register exit function.\n"); } - succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); if (!succp) { @@ -139,7 +139,7 @@ int main(int argc, char* argv[]) tm.tm_min, tm.tm_sec); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("First write with flush."); err = skygw_log_write_flush(LOGFILE_ERROR, logstr); @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) #endif logstr = "My name is Stacey %s"; err = skygw_log_write_flush(LOGFILE_TRACE, logstr, " "); - skygw_logmanager_done(); + mxs_log_finish(); #if !defined(SS_DEBUG) skygw_log_enable(LOGFILE_TRACE); #endif @@ -187,7 +187,7 @@ int main(int argc, char* argv[]) logstr = "Ph%dlip."; err = skygw_log_write(LOGFILE_TRACE, logstr, 1); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("A terrible error has occurred!"); err = skygw_log_write_flush(LOGFILE_ERROR, logstr); @@ -209,7 +209,7 @@ int main(int argc, char* argv[]) "with us. Just me and my mom - and you, of course. Then, if you wish, we could " "listen to the radio and keep company for our little Steven, my mom's cat, you know."); err = skygw_log_write(LOGFILE_MESSAGE, logstr); - skygw_logmanager_done(); + mxs_log_finish(); #if defined(TEST1) mes = skygw_message_init(); @@ -252,7 +252,7 @@ int main(int argc, char* argv[]) pthread_join(thr[i]->tid, NULL); } /** This is to release memory */ - skygw_logmanager_done(); + mxs_log_finish(); simple_mutex_unlock(mtx); @@ -309,7 +309,7 @@ int main(int argc, char* argv[]) pthread_join(thr[i]->tid, NULL); } /** This is to release memory */ - skygw_logmanager_done(); + mxs_log_finish(); simple_mutex_unlock(mtx); @@ -333,7 +333,7 @@ int main(int argc, char* argv[]) #if !defined(SS_DEBUG) skygw_log_enable(LOGFILE_TRACE); #endif - succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); ss_dassert(succp); logstr = ("\tTEST 3 - test enabling and disabling logs."); @@ -393,12 +393,12 @@ int main(int argc, char* argv[]) err = skygw_log_write(LOGFILE_ERROR, logstr); ss_dassert(err == 0); - skygw_logmanager_done(); + mxs_log_finish(); #endif /* TEST 3 */ #if defined(TEST4) - succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); ss_dassert(succp); #if !defined(SS_DEBUG) skygw_log_enable(LOGFILE_TRACE); @@ -432,9 +432,9 @@ int main(int argc, char* argv[]) err = skygw_log_write(LOGFILE_MESSAGE, logstr); ss_dassert(err == 0); - skygw_logmanager_done(); + mxs_log_finish(); - succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); ss_dassert(succp); #if !defined(SS_DEBUG) skygw_log_enable(LOGFILE_TRACE); @@ -488,7 +488,7 @@ int main(int argc, char* argv[]) ss_dassert(err == 0); - skygw_logmanager_done(); + mxs_log_finish(); #endif /* TEST 4 */ fprintf(stderr, ".. done.\n"); @@ -507,7 +507,7 @@ static void* thr_run(void* data) char* logstr; int err; - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); skygw_log_flush(LOGFILE_MESSAGE); logstr = ("Hi, how are you?"); err = skygw_log_write(LOGFILE_MESSAGE, logstr); @@ -517,7 +517,7 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_done(); + mxs_log_finish(); skygw_log_flush(LOGFILE_TRACE); skygw_log_flush(LOGFILE_MESSAGE); logstr = ("I was wondering, you know, it has been such a lovely weather whole morning and " @@ -531,7 +531,7 @@ static void* thr_run(void* data) } ss_dassert(err == 0); err = skygw_log_write(LOGFILE_MESSAGE, logstr); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("Testing. One, two, three\n"); err = skygw_log_write(LOGFILE_ERROR, logstr); if (err != 0) @@ -539,8 +539,8 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); skygw_log_flush(LOGFILE_ERROR); logstr = ("For automatic and register variables, it is done each time the function or block is entered."); @@ -553,8 +553,8 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_done(); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("Rather more surprising, at least at first sight, is the fact that a reference " "to a[i] can also be written as *(a+i). In evaluating a[i], C converts it to *(a+i) " "immediately; the two forms are equivalent. Applying the operatos & to both parts " @@ -566,11 +566,11 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); - skygw_logmanager_done(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); skygw_log_flush(LOGFILE_ERROR); - skygw_logmanager_done(); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("..and you?"); err = skygw_log_write(LOGFILE_MESSAGE, logstr); if (err != 0) @@ -578,8 +578,8 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_done(); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("For automatic and register variables, it is done each time the function or block is entered."); #if !defined(SS_DEBUG) skygw_log_enable(LOGFILE_TRACE); @@ -590,7 +590,7 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("Rather more surprising, at least at first sight, is the fact that a reference to " "a[i] can also be written as *(a+i). In evaluating a[i], C converts it to *(a+i) " "immediately; the two forms are equivalent. Applying the operatos & to both parts " @@ -602,7 +602,7 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("..... and you too?"); err = skygw_log_write(LOGFILE_MESSAGE, logstr); if (err != 0) @@ -610,8 +610,8 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_done(); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); #if !defined(SS_DEBUG) skygw_log_enable(LOGFILE_TRACE); #endif @@ -626,8 +626,8 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_done(); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("Testing. One, two, three, four\n"); err = skygw_log_write(LOGFILE_ERROR, logstr); if (err != 0) @@ -635,8 +635,8 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_done(); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); logstr = ("Testing. One, two, three, .. where was I?\n"); err = skygw_log_write(LOGFILE_ERROR, logstr); if (err != 0) @@ -644,9 +644,9 @@ static void* thr_run(void* data) TEST_ERROR("Error, log write failed."); } ss_dassert(err == 0); - skygw_logmanager_done(); - skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS); - skygw_logmanager_done(); + mxs_log_finish(); + mxs_log_init(NULL, "/tmp", LOG_TARGET_FS); + mxs_log_finish(); simple_mutex_lock(td->mtx, true); *td->nactive -= 1; simple_mutex_unlock(td->mtx); diff --git a/log_manager/test/testorder.c b/log_manager/test/testorder.c index 757cfd5bb..7656e8b94 100644 --- a/log_manager/test/testorder.c +++ b/log_manager/test/testorder.c @@ -67,7 +67,7 @@ int main(int argc, char** argv) iterations = atoi(argv[1]); interval = atoi(argv[2]); - succp = skygw_logmanager_init(NULL, tmp, LOG_TARGET_FS); + succp = mxs_log_init(NULL, tmp, LOG_TARGET_FS); if (!succp) { @@ -108,7 +108,7 @@ int main(int argc, char** argv) } skygw_log_flush(LOGFILE_ERROR); - skygw_logmanager_done(); + mxs_log_finish(); free(message); return 0; } diff --git a/server/core/gateway.c b/server/core/gateway.c index 051387071..338c90b8c 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -1081,10 +1081,7 @@ int main(int argc, char **argv) sigset_t sigset; sigset_t sigpipe_mask; sigset_t saved_mask; - void (*exitfunp[4])(void) = {skygw_logmanager_exit, - datadir_cleanup, - write_footer, - NULL}; + void (*exitfunp[4])(void) = { mxs_log_finish, datadir_cleanup, write_footer, NULL }; *syslog_enabled = 1; *maxscalelog_enabled = 1; @@ -1719,7 +1716,7 @@ int main(int argc, char **argv) logmanager_enable_syslog(*syslog_enabled); logmanager_enable_maxscalelog(*maxscalelog_enabled); - succp = skygw_logmanager_init(NULL, get_logdir(), log_target); + succp = mxs_log_init(NULL, get_logdir(), log_target); if (!succp) { diff --git a/server/core/maxkeys.c b/server/core/maxkeys.c index 3b74d39af..14e94f9bb 100644 --- a/server/core/maxkeys.c +++ b/server/core/maxkeys.c @@ -48,7 +48,7 @@ int main(int argc, char **argv) keyfile = argv[1]; } - skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT); + mxs_log_init(NULL, NULL, LOG_TARGET_DEFAULT); if (secrets_writeKeys(keyfile)) { @@ -57,7 +57,7 @@ int main(int argc, char **argv) } skygw_log_sync_all(); - skygw_logmanager_done(); + mxs_log_finish(); return rval; } diff --git a/server/core/maxpasswd.c b/server/core/maxpasswd.c index 1742b9341..9afe83d98 100644 --- a/server/core/maxpasswd.c +++ b/server/core/maxpasswd.c @@ -51,7 +51,7 @@ main(int argc, char **argv) return 1; } - skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT); + mxs_log_init(NULL, NULL, LOG_TARGET_DEFAULT); pw = calloc(81, sizeof(char)); @@ -75,6 +75,6 @@ main(int argc, char **argv) free(pw); skygw_log_sync_all(); - skygw_logmanager_done(); + mxs_log_finish(); return rval; } diff --git a/server/include/test_utils.h b/server/include/test_utils.h index f6707e9ca..53bcbb379 100644 --- a/server/include/test_utils.h +++ b/server/include/test_utils.h @@ -12,7 +12,7 @@ void init_test_env(char *path) const char* logdir = path ? path : TEST_LOG_DIR; - skygw_logmanager_init(NULL, logdir, LOG_TARGET_DEFAULT); + mxs_log_init(NULL, logdir, LOG_TARGET_DEFAULT); poll_init(); hkinit(); } diff --git a/server/modules/filter/dbfwfilter.c b/server/modules/filter/dbfwfilter.c index 8f64139c8..0d72f7ccb 100644 --- a/server/modules/filter/dbfwfilter.c +++ b/server/modules/filter/dbfwfilter.c @@ -2213,7 +2213,7 @@ int main(int argc, char** argv) NULL }; - skygw_logmanager_init(argc_,argv_); + mxs_log_init(argc_,argv_); init_test_env(home); diff --git a/server/modules/filter/test/harness_common.c b/server/modules/filter/test/harness_common.c index 0dc79909d..0b8510263 100644 --- a/server/modules/filter/test/harness_common.c +++ b/server/modules/filter/test/harness_common.c @@ -17,7 +17,7 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){ char tmp[2048]; if(!(argc == 2 && strcmp(argv[1],"-h") == 0)){ - skygw_logmanager_init(NULL,NULL,LOG_TARGET_DEFAULT); + mxs_log_init(NULL,NULL,LOG_TARGET_DEFAULT); } if(!(instance.head = calloc(1,sizeof(FILTERCHAIN)))) @@ -51,7 +51,7 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){ getcwd(cwd,sizeof(cwd)); sprintf(tmp,"%s",cwd); - skygw_logmanager_init(NULL, tmp, LOG_TARGET_DEFAULT); + mxs_log_init(NULL, tmp, LOG_TARGET_DEFAULT); rval = process_opts(argc,argv); diff --git a/server/modules/filter/test/harness_ui.c b/server/modules/filter/test/harness_ui.c index fa8d14e3d..b92182a37 100644 --- a/server/modules/filter/test/harness_ui.c +++ b/server/modules/filter/test/harness_ui.c @@ -11,8 +11,7 @@ int main(int argc, char** argv){ if(harness_init(argc,argv,&hinstance)){ printf("Error: Initialization failed.\n"); skygw_log_write(LOGFILE_ERROR,"Error: Initialization failed.\n"); - skygw_logmanager_done(); - skygw_logmanager_exit(); + mxs_log_finish(); return 1; } @@ -230,8 +229,7 @@ int main(int argc, char** argv){ free_buffers(); free_filters(); - skygw_logmanager_done(); - skygw_logmanager_exit(); + mxs_log_finish(); free(instance.head); return 0; diff --git a/server/modules/filter/test/harness_util.c b/server/modules/filter/test/harness_util.c index 5b3baf31e..16d10c8c4 100644 --- a/server/modules/filter/test/harness_util.c +++ b/server/modules/filter/test/harness_util.c @@ -35,8 +35,7 @@ int main(int argc,char** argv) if(harness_init(argc,argv,&inst) || inst->error){ printf("Error: Initialization failed.\n"); skygw_log_write(LOGFILE_ERROR,"Error: Initialization failed.\n"); - skygw_logmanager_done(); - skygw_logmanager_exit(); + mxs_log_finish(); return 1; } diff --git a/server/modules/routing/binlog/maxbinlogcheck.c b/server/modules/routing/binlog/maxbinlogcheck.c index 016f43235..0af03b0b8 100644 --- a/server/modules/routing/binlog/maxbinlogcheck.c +++ b/server/modules/routing/binlog/maxbinlogcheck.c @@ -124,7 +124,7 @@ int main(int argc, char **argv) { num_args = optind; - skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT); + mxs_log_init(NULL, NULL, LOG_TARGET_DEFAULT); skygw_log_set_augmentation(0); @@ -138,7 +138,7 @@ int main(int argc, char **argv) { "Error: Memory allocation failed for ROUTER_INSTANCE"))); skygw_log_sync_all(); - skygw_logmanager_done(); + mxs_log_finish(); return 1; } @@ -162,7 +162,7 @@ int main(int argc, char **argv) { path, strerror(errno)))); skygw_log_sync_all(); - skygw_logmanager_done(); + mxs_log_finish(); free(inst); @@ -200,7 +200,7 @@ int main(int argc, char **argv) { "Check retcode: %i, Binlog Pos = %llu", ret, inst->binlog_position))); skygw_log_sync_all(); - skygw_logmanager_done(); + mxs_log_finish(); free(inst); diff --git a/server/modules/routing/binlog/test/testbinlog.c b/server/modules/routing/binlog/test/testbinlog.c index 2cb796ea8..b034307cf 100644 --- a/server/modules/routing/binlog/test/testbinlog.c +++ b/server/modules/routing/binlog/test/testbinlog.c @@ -89,7 +89,7 @@ int main(int argc, char **argv) { roptions = strdup("server-id=3,heartbeat=200,binlogdir=/not_exists/my_dir,transaction_safety=1,master_version=5.6.99-common,master_hostname=common_server,master_uuid=xxx-fff-cccc-fff,master-id=999"); - skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT); + mxs_log_init(NULL, NULL, LOG_TARGET_DEFAULT); skygw_log_disable(LOGFILE_DEBUG); skygw_log_disable(LOGFILE_TRACE); @@ -128,7 +128,7 @@ int main(int argc, char **argv) { "Error: Memory allocation FAILED for ROUTER_INSTANCE"))); skygw_log_sync_all(); - skygw_logmanager_done(); + mxs_log_finish(); return 1; } @@ -579,7 +579,7 @@ int main(int argc, char **argv) { } skygw_log_sync_all(); - skygw_logmanager_done(); + mxs_log_finish(); free(inst);