Log: No more argv parsing for log manager.

Earlier, the global setting for the syslog decided whether syslog
was enabled when skygw_logmanager_init was called, but not whether
logging to syslog actually was made.

Now syslog logging is enabled by default and the global setting
decides whether or not syslog logging actually is made. That is,
this opens up the possiblity for making it possible to turn on
and off sysloging at runtime.

Further, although the API led you to believe otherwise, it was
hardwired that LOGFILE_ERROR and LOGFILE_MESSAGE messages were
written to syslog.

The changed removed the need for passing an argv array explicitly.
This commit is contained in:
Johan Wikman 2015-11-10 14:37:49 +02:00
parent 0b7de96eff
commit acb0a523a7
11 changed files with 56 additions and 211 deletions

View File

@ -184,7 +184,6 @@ struct logfile
flat_obj_state_t lf_state;
bool lf_init_started;
bool lf_store_shmem;
bool lf_write_syslog;
logmanager_t* lf_lmgr;
/** fwr_logmes is for messages from log clients */
skygw_message_t* lf_logmes;
@ -260,8 +259,7 @@ typedef struct strpart
static bool logfiles_init(logmanager_t* lmgr);
static bool logfile_init(logfile_t* logfile,
logmanager_t* logmanager,
bool store_shmem,
bool write_syslog);
bool store_shmem);
static void logfile_done(logfile_t* logfile);
static void logfile_free_memory(logfile_t* lf);
static void logfile_flush(logfile_t* lf);
@ -275,7 +273,7 @@ static bool filewriter_init(logmanager_t* logmanager,
skygw_message_t* clientmes,
skygw_message_t* logmes);
static void filewriter_done(filewriter_t* filewriter);
static bool fnames_conf_init(fnames_conf_t* fn, const char* logdir, int argc, char* argv[]);
static bool fnames_conf_init(fnames_conf_t* fn, const char* logdir);
static void fnames_conf_done(fnames_conf_t* fn);
static void fnames_conf_free_memory(fnames_conf_t* fn);
static void* thr_filewriter_fun(void* data);
@ -284,8 +282,7 @@ static bool logmanager_register(bool writep);
static void logmanager_unregister(void);
static bool logmanager_init_nomutex(const char* ident,
const char* logdir,
log_target_t target,
int argc, char* argv[]);
log_target_t target);
static void logmanager_done_nomutex(void);
static bool logmanager_is_valid_id(logfile_id_t id);
@ -318,8 +315,7 @@ bool thr_flushall_check();
static bool logmanager_init_nomutex(const char* ident,
const char* logdir,
log_target_t target,
int argc, char* argv[])
log_target_t target)
{
fnames_conf_t* fn;
filewriter_t* fw;
@ -365,7 +361,7 @@ static bool logmanager_init_nomutex(const char* ident,
openlog(ident, LOG_PID | LOG_ODELAY, LOG_USER);
/** Initialize configuration including log file naming info */
if (!fnames_conf_init(fn, logdir, argc, argv))
if (!fnames_conf_init(fn, logdir))
{
err = 1;
goto return_succp;
@ -431,16 +427,11 @@ return_succp:
* @param logdir The directory for the log file. If NULL logging will be made to stdout.
* @param target Whether the log should be written to filesystem or shared memory.
* Meaningless if logdir is NULL.
* @param argc Number of arguments in argv array.
* @param argv Arguments array.
*
* @return true if succeed, otherwise false
*
*/
bool skygw_logmanager_init(const char* ident,
const char* logdir,
log_target_t target,
int argc, char* argv[])
bool skygw_logmanager_init(const char* ident, const char* logdir, log_target_t target)
{
bool succp = false;
@ -448,11 +439,13 @@ bool skygw_logmanager_init(const char* ident,
if (lm != NULL)
{
// TODO: This is not ok. If the parameters are different then
// TODO: we pretend something is what it is not.
succp = true;
goto return_succp;
}
succp = logmanager_init_nomutex(ident, logdir, target, argc, argv);
succp = logmanager_init_nomutex(ident, logdir, target);
return_succp:
release_lock(&lmlock);
@ -785,7 +778,7 @@ static int logmanager_write_log(logfile_id_t id,
memset(wp + safe_str_len - 4, '.', 3);
}
/** write to syslog */
if (lf->lf_write_syslog)
if (log_config.do_syslog)
{
// Strip away the timestamp and the prefix (e.g. "[Error]: ").
const char *message = wp + timestamp_len + prefix_len;
@ -1638,7 +1631,7 @@ static bool logmanager_register(bool writep)
// If someone is logging before the log manager has been inited,
// or after the log manager has been finished, the messages are
// written to stdout.
succp = logmanager_init_nomutex(NULL, NULL, LOG_TARGET_DEFAULT, 0, NULL);
succp = logmanager_init_nomutex(NULL, NULL, LOG_TARGET_DEFAULT);
}
}
/** if logmanager existed or was succesfully restarted, increase link */
@ -1687,24 +1680,15 @@ static void logmanager_unregister(void)
*
* @param fn The fnames_conf_t structure to initialize.
* @param logdir The directory for the log file. If NULL logging will be made to stdout.
* @param argc number of arguments in argv array
* @param argv arguments array
*
* @return True if the initialization was performed, false otherwise.
*
* @details Note that input parameter lenghts are checked here.
*
*/
static bool fnames_conf_init(fnames_conf_t* fn,
const char* logdir,
int argc,
char* argv[])
static bool fnames_conf_init(fnames_conf_t* fn, const char* logdir)
{
int opt;
bool succp = false;
const char* argstr =
"-h - help\n"
"-l <syslog log file ids> .......(no default)\n";
bool succp = false;
/**
* When init_started is set, clean must be done for it.
@ -1714,60 +1698,28 @@ static bool fnames_conf_init(fnames_conf_t* fn,
fn->fn_chk_top = CHK_NUM_FNAMES;
fn->fn_chk_tail = CHK_NUM_FNAMES;
#endif
optind = 1; /**<! reset getopt index */
while ((opt = getopt(argc, argv, "+h:l:")) != -1)
{
switch (opt)
{
case 'l':
/** record list of log file ids for syslogged */
if (log_config.do_syslog)
{
if (syslog_id_str != NULL)
{
free (syslog_id_str);
}
syslog_id_str = optarg;
}
break;
case 'h':
default:
fprintf(stderr, "\nSupported arguments are (default)\n%s\n", argstr);
goto return_conf_init;
} /** switch (opt) */
}
const char* dir;
if (logdir)
{
log_config.use_stdout = 0;
fn->fn_logpath = strdup(logdir);
dir = logdir;
}
else
{
log_config.use_stdout = 1;
// TODO: Re-arrange things so that fn->fn_logpath can be NULL.
fn->fn_logpath = strdup("/tmp"); // Not used.
dir = "/tmp";
}
#if defined(NOT_USED)
fprintf(stderr,
"Log :\t%s/%s1%s\n\n",
fn->fn_logpath,
LOGFILE_NAME_PREFIX,
LOGFILE_NAME_SUFFIX);
#endif
succp = true;
fn->fn_state = RUN;
CHK_FNAMES_CONF(fn);
fn->fn_logpath = strdup(dir);
return_conf_init:
if (!succp)
if (fn->fn_logpath)
{
fnames_conf_done(fn);
succp = true;
fn->fn_state = RUN;
CHK_FNAMES_CONF(fn);
}
ss_dassert(fn->fn_state == RUN || fn->fn_state == DONE);
return succp;
}
@ -1792,27 +1744,9 @@ return_conf_init:
*/
static bool logfiles_init(logmanager_t* lm)
{
bool succp = true;
bool store_shmem = (lm->lm_target == LOG_TARGET_SHMEM);
bool write_syslog;
bool store_shmem = (lm->lm_target == LOG_TARGET_SHMEM);
/**
* Check if file is also written to syslog.
*/
if (syslog_id_str != NULL &&
strcasestr(syslog_id_str, STRLOGID(LOGFILE_ERROR)) != NULL)
{
write_syslog = true;
}
else
{
write_syslog = false;
}
succp = logfile_init(&lm->lm_logfile,
lm,
store_shmem,
write_syslog);
bool succp = logfile_init(&lm->lm_logfile, lm, store_shmem);
if (!succp)
{
@ -2299,14 +2233,12 @@ static bool file_is_symlink(char* filename)
* @param logfile log file
* @param logmanager log manager pointer
* @param store_shmem flag to indicate whether log is physically written to shmem
* @param write_syslog flag to indicate whether log is also written to syslog
*
* @return true if succeed, false otherwise
*/
static bool logfile_init(logfile_t* logfile,
logmanager_t* logmanager,
bool store_shmem,
bool write_syslog)
bool store_shmem)
{
bool succp = false;
fnames_conf_t* fn = &logmanager->lm_fnames_conf;
@ -2325,7 +2257,6 @@ static bool logfile_init(logfile_t* logfile,
logfile->lf_rotateflag = false;
logfile->lf_spinlock = 0;
logfile->lf_store_shmem = store_shmem;
logfile->lf_write_syslog = write_syslog;
logfile->lf_buf_size = MAX_LOGSTRLEN;
/**
* If file is stored in shared memory in /dev/shm, a link

View File

@ -153,8 +153,7 @@ int mxs_log_disable_priority(int priority);
bool skygw_logmanager_init(const char* ident,
const char* logdir,
log_target_t target,
int argc, char* argv[]);
log_target_t target);
void skygw_logmanager_done(void);
void skygw_logmanager_exit(void);

View File

@ -77,8 +77,6 @@ int main(int argc, char* argv[])
struct tm tm;
char c;
int nthr = N_THR;
int log_argc = 0;
char** log_argv = NULL;
while ((c = getopt(argc, argv, "t:")) != -1)
{
@ -122,7 +120,7 @@ int main(int argc, char* argv[])
fprintf(stderr, "Couldn't register exit function.\n");
}
succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, log_argc, log_argv);
succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
if (!succp)
{
@ -141,7 +139,7 @@ int main(int argc, char* argv[])
tm.tm_min,
tm.tm_sec);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, log_argc, log_argv);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("First write with flush.");
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
@ -189,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, log_argc, log_argv);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("A terrible error has occurred!");
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
@ -335,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, log_argc, log_argv);
succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
ss_dassert(succp);
logstr = ("\tTEST 3 - test enabling and disabling logs.");
@ -400,7 +398,7 @@ int main(int argc, char* argv[])
#endif /* TEST 3 */
#if defined(TEST4)
succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, log_argc, log_argv);
succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
ss_dassert(succp);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
@ -436,7 +434,7 @@ int main(int argc, char* argv[])
skygw_logmanager_done();
succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, log_argc, log_argv);
succp = skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
ss_dassert(succp);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
@ -509,7 +507,7 @@ static void* thr_run(void* data)
char* logstr;
int err;
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
skygw_log_flush(LOGFILE_MESSAGE);
logstr = ("Hi, how are you?");
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
@ -533,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, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("Testing. One, two, three\n");
err = skygw_log_write(LOGFILE_ERROR, logstr);
if (err != 0)
@ -541,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, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
skygw_logmanager_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.");
@ -556,7 +554,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_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 "
@ -568,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, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
skygw_logmanager_done();
skygw_log_flush(LOGFILE_ERROR);
skygw_logmanager_done();
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("..and you?");
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
if (err != 0)
@ -581,7 +579,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_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);
@ -592,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, 0, NULL);
skygw_logmanager_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 "
@ -604,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, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("..... and you too?");
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
if (err != 0)
@ -613,7 +611,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
#if !defined(SS_DEBUG)
skygw_log_enable(LOGFILE_TRACE);
#endif
@ -629,7 +627,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
logstr = ("Testing. One, two, three, four\n");
err = skygw_log_write(LOGFILE_ERROR, logstr);
if (err != 0)
@ -638,7 +636,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_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)
@ -647,7 +645,7 @@ static void* thr_run(void* data)
}
ss_dassert(err == 0);
skygw_logmanager_done();
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS, 0, NULL);
skygw_logmanager_init(NULL, "/tmp", LOG_TARGET_FS);
skygw_logmanager_done();
simple_mutex_lock(td->mtx, true);
*td->nactive -= 1;

View File

@ -31,7 +31,6 @@ int main(int argc, char** argv)
char cwd[1024];
char tmp[2048];
char *message;
char** optstr;
long msg_index = 1;
struct timespec ts1;
ts1.tv_sec = 0;
@ -55,7 +54,6 @@ int main(int argc, char** argv)
}
if (getcwd(cwd, sizeof(cwd)) == NULL ||
(optstr = (char**)malloc(sizeof(char*) * 4)) == NULL ||
(message = (char*)malloc(sizeof(char) * block_size)) == NULL)
{
fprintf(stderr,"Fatal Error, exiting...");
@ -65,13 +63,11 @@ int main(int argc, char** argv)
memset(tmp, 0, 1024);
sprintf(tmp, "%s", cwd);
optstr[0] = strdup("log_manager");
optstr[1] = NULL;
iterations = atoi(argv[1]);
interval = atoi(argv[2]);
succp = skygw_logmanager_init(NULL, tmp, LOG_TARGET_FS, 1, optstr);
succp = skygw_logmanager_init(NULL, tmp, LOG_TARGET_FS);
if (!succp)
{
@ -114,10 +110,5 @@ int main(int argc, char** argv)
skygw_log_flush(LOGFILE_ERROR);
skygw_logmanager_done();
free(message);
free(optstr[0]);
free(optstr[1]);
free(optstr[2]);
free(optstr[3]);
free(optstr);
return 0;
}

View File

@ -1089,7 +1089,7 @@ int main(int argc, char **argv)
write_footer,
NULL};
*syslog_enabled = 0;
*syslog_enabled = 1;
*maxscalelog_enabled = 1;
sigemptyset(&sigpipe_mask);
@ -1698,9 +1698,6 @@ int main(int argc, char **argv)
/**
* Init Log Manager for MaxScale.
* The skygw_logmanager_init expects to take arguments as passed to main
* and proesses them with getopt, therefore we need to give it a dummy
* argv[0]
*/
{
bool succp;
@ -1713,8 +1710,6 @@ int main(int argc, char **argv)
goto return_main;
}
argv[0] = "MaxScale";
if (!(*syslog_enabled))
{
printf("Syslog logging is disabled.\n");
@ -1727,10 +1722,7 @@ int main(int argc, char **argv)
logmanager_enable_syslog(*syslog_enabled);
logmanager_enable_maxscalelog(*maxscalelog_enabled);
char* log_argv[] = { "MaxScale", "-l", "LOGFILE_MESSAGE,LOGFILE_ERROR", NULL };
int log_argc = sizeof(log_argv) / sizeof(log_argv[0]) - 1;
succp = skygw_logmanager_init(NULL, get_logdir(), log_target, log_argc, log_argv);
succp = skygw_logmanager_init(NULL, get_logdir(), log_target);
if (!succp)
{

View File

@ -35,10 +35,7 @@
int main(int argc, char **argv)
{
int arg_count = 1;
char *home;
char *keyfile;
char** arg_vector;
int rval = 0;
if (argc < 2)
@ -50,18 +47,8 @@ int main(int argc, char **argv)
{
keyfile = argv[1];
}
arg_vector = malloc(sizeof(char*) * (arg_count + 1));
if (arg_vector == NULL)
{
fprintf(stderr,"Error: Memory allocation failed.\n");
return 1;
}
arg_vector[0] = "logmanager";
arg_vector[1] = NULL;
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT, arg_count, arg_vector);
free(arg_vector);
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT);
if (secrets_writeKeys(keyfile))
{

View File

@ -42,9 +42,7 @@ main(int argc, char **argv)
{
char *enc;
char *pw;
int arg_count = 1;
char *home;
char** arg_vector;
int rval = 0;
if (argc != 3)
@ -53,18 +51,7 @@ main(int argc, char **argv)
return 1;
}
arg_vector = malloc(sizeof(char*) * (arg_count + 1));
if (arg_vector == NULL)
{
fprintf(stderr,"Error: Memory allocation failed.\n");
return 1;
}
arg_vector[0] = "logmanager";
arg_vector[1] = NULL;
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT, arg_count, arg_vector);
free(arg_vector);
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT);
pw = calloc(81, sizeof(char));

View File

@ -12,15 +12,7 @@ void init_test_env(char *path)
const char* logdir = path ? path : TEST_LOG_DIR;
char* argv[] =
{
"log_manager",
"-l",
"LOGFILE_ERROR",
NULL
};
skygw_logmanager_init(NULL, logdir, LOG_TARGET_DEFAULT, argc, argv);
skygw_logmanager_init(NULL, logdir, LOG_TARGET_DEFAULT);
poll_init();
hkinit();
}

View File

@ -15,10 +15,9 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){
DCB* dcb;
char cwd[1024];
char tmp[2048];
char** optstr;
if(!(argc == 2 && strcmp(argv[1],"-h") == 0)){
skygw_logmanager_init(NULL,NULL,LOG_TARGET_DEFAULT,0,NULL);
skygw_logmanager_init(NULL,NULL,LOG_TARGET_DEFAULT);
}
if(!(instance.head = calloc(1,sizeof(FILTERCHAIN))))
@ -52,11 +51,7 @@ int harness_init(int argc, char** argv, HARNESS_INSTANCE** inst){
getcwd(cwd,sizeof(cwd));
sprintf(tmp,"%s",cwd);
optstr = (char**)malloc(sizeof(char*)*2);
optstr[0] = strdup("log_manager");
optstr[1] = NULL;
skygw_logmanager_init(NULL, tmp, LOG_TARGET_DEFAULT, 1, optstr);
free(optstr);
skygw_logmanager_init(NULL, tmp, LOG_TARGET_DEFAULT);
rval = process_opts(argc,argv);

View File

@ -86,8 +86,6 @@ return 1;
}
int main(int argc, char **argv) {
char** arg_vector;
int arg_count = 1;
ROUTER_INSTANCE *inst;
int fd;
int ret;
@ -126,22 +124,10 @@ int main(int argc, char **argv) {
num_args = optind;
arg_vector = malloc(sizeof(char*)*(arg_count + 1));
if(arg_vector == NULL)
{
fprintf(stderr,"Error: Memory allocation failed for log manager arg_vector.\n");
return 1;
}
arg_vector[0] = "logmanager";
arg_vector[1] = NULL;
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT, arg_count, arg_vector);
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT);
skygw_log_set_augmentation(0);
free(arg_vector);
if (!debug_out)
skygw_log_disable(LOGFILE_DEBUG);
else

View File

@ -73,11 +73,9 @@ static struct option long_options[] = {
};
int main(int argc, char **argv) {
char** arg_vector;
ROUTER_INSTANCE *inst;
int ret;
int rc;
int arg_count = 1;
char error_string[BINLOG_ERROR_MSG_LEN + 1] = "";
CHANGE_MASTER_OPTIONS change_master;
char query[255+1]="";
@ -91,18 +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");
arg_vector = malloc(sizeof(char*)*(arg_count + 1));
if(arg_vector == NULL)
{
fprintf(stderr,"Error: Memory allocation FAILED for log manager arg_vector.\n");
return 1;
}
arg_vector[0] = "logmanager";
arg_vector[1] = NULL;
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT, arg_count,arg_vector);
free(arg_vector);
skygw_logmanager_init(NULL, NULL, LOG_TARGET_DEFAULT);
skygw_log_disable(LOGFILE_DEBUG);
skygw_log_disable(LOGFILE_TRACE);