log_manager.cc

Added global variable lm_enabled_logfiles_bitmask which holds a bit for each enbaled logfile. It is updated when situation changes. 

gateway.c
	Changed gateway.c:main so that command-line argument -f specifies either the name of config file in $MAXSCALE_HOME/etc or exact location and name of it. Updated README correspondingly.
	Added eternal variable lm_enabled_logfiles_bitmask to be used for quick check before calling logging library functions.
This commit is contained in:
vraatikka 2013-12-04 09:56:48 +02:00
parent 84fbf15bef
commit 258bcb27da
3 changed files with 36 additions and 6 deletions

6
README
View File

@ -73,8 +73,6 @@ MAXSCALE_HOME can be overriden by use of the -c flag on the command
line. This should be immediately followed by the path to the MaxScale
home directory.
The -f flag can be used to set the name of the configuration file
to read in place of the one in the MaxScale home directory. Merely
pass the name of the file to read followinf the -f flag.
The -f flag can be used to set the name and the location of the configuration
file. Without path expression the file is read from $MAXSCALE_HOME/etc directory.
*/

View File

@ -43,6 +43,12 @@
extern char *program_invocation_name;
extern char *program_invocation_short_name;
/**
* Variable holding the enabled logfiles information.
* Used from log users to check enabled logs prior calling
* actual library calls such as skygw_log_write.
*/
int lm_enabled_logfiles_bitmask = 0;
/**
* BUFSIZ comes from the system. It equals with block size or
@ -340,6 +346,11 @@ static bool logmanager_init_nomutex(
fw = &lm->lm_filewriter;
fn->fn_state = UNINIT;
fw->fwr_state = UNINIT;
/**
* Set global variable
*/
lm_enabled_logfiles_bitmask = lm->lm_enabled_logfiles;
/** Initialize configuration including log file naming info */
if (!fnames_conf_init(fn, argc, argv)) {
@ -1016,6 +1027,10 @@ int skygw_log_enable(
if (logfile_set_enabled(id, true)) {
lm->lm_enabled_logfiles |= id;
/**
* Set global variable
*/
lm_enabled_logfiles_bitmask = lm->lm_enabled_logfiles;
}
logmanager_unregister();
@ -1038,6 +1053,10 @@ int skygw_log_disable(
if (logfile_set_enabled(id, false)) {
lm->lm_enabled_logfiles &= ~id;
/**
* Set global variable
*/
lm_enabled_logfiles_bitmask = lm->lm_enabled_logfiles;
}
logmanager_unregister();

View File

@ -66,6 +66,13 @@
extern char *program_invocation_name;
extern char *program_invocation_short_name;
/**
* Variable holding the enabled logfiles information.
* Used from log users to check enabled logs prior calling
* actual library calls such as skygw_log_write.
*/
extern int lm_enabled_logfiles_bitmask;
/*
* Server options are passed to the mysql_server_init. Each gateway must have a unique
* data directory that is passed to the mysql_server_init, therefore the data directory
@ -345,6 +352,7 @@ static bool resolve_maxscale_conf_fname(
if (cnf_file_arg != NULL)
{
char* home_etc_dir;
/**
* 1. argument is valid full pathname
* '- /home/jdoe/MaxScale/myconf.cnf'
@ -360,9 +368,15 @@ static bool resolve_maxscale_conf_fname(
* directory.
* '-f MaxScale.cnf'
*/
home_etc_dir = (char*)malloc(strlen(home_dir)+strlen("/etc")+1);
snprintf(home_etc_dir,
strlen(home_dir)+strlen("/etc")+1,
"%s/etc",
home_dir);
*cnf_full_path = get_expanded_pathname(NULL,
home_dir,
home_etc_dir,
cnf_file_arg);
free(home_etc_dir);
if (*cnf_full_path != NULL)
{
@ -1215,7 +1229,6 @@ int main(int argc, char **argv)
"Configuration file : %s",
cnf_file_path);
/* Update the server options */
for (i = 0; server_options[i]; i++)
{