More obsolete functionality removed.

The log manager possibility for explicitly specifying the names
of the log files has never been used. In the name of simplicity
that functionality is removed.
This commit is contained in:
Johan Wikman
2015-11-04 11:00:38 +02:00
parent 865162dc54
commit e9ff89629b
2 changed files with 15 additions and 78 deletions

View File

@ -43,6 +43,9 @@
# define _GNU_SOURCE # define _GNU_SOURCE
#endif #endif
static const char LOGFILE_NAME_PREFIX[] = "error";
static const char LOGFILE_NAME_SUFFIX[] = ".log";
extern char *program_invocation_name; extern char *program_invocation_name;
extern char *program_invocation_short_name; extern char *program_invocation_short_name;
@ -180,8 +183,8 @@ struct logfile
skygw_message_t* lf_logmes; skygw_message_t* lf_logmes;
char* lf_filepath; /**< path to file used for logging */ char* lf_filepath; /**< path to file used for logging */
char* lf_linkpath; /**< path to symlink file. */ char* lf_linkpath; /**< path to symlink file. */
char* lf_name_prefix; const char* lf_name_prefix;
char* lf_name_suffix; const char* lf_name_suffix;
int lf_name_seqno; int lf_name_seqno;
char* lf_full_file_name; /**< complete log file name */ char* lf_full_file_name; /**< complete log file name */
char* lf_full_link_name; /**< complete symlink name */ char* lf_full_link_name; /**< complete symlink name */
@ -206,8 +209,6 @@ struct fnames_conf
skygw_chk_t fn_chk_top; skygw_chk_t fn_chk_top;
#endif #endif
flat_obj_state_t fn_state; flat_obj_state_t fn_state;
char* fn_err_prefix;
char* fn_err_suffix;
char* fn_logpath; char* fn_logpath;
#if defined(SS_DEBUG) #if defined(SS_DEBUG)
skygw_chk_t fn_chk_tail; skygw_chk_t fn_chk_tail;
@ -242,7 +243,7 @@ struct logmanager
typedef struct strpart typedef struct strpart
{ {
char* sp_string; const char* sp_string;
struct strpart* sp_next; struct strpart* sp_next;
} strpart_t; } strpart_t;
@ -269,8 +270,6 @@ static void filewriter_done(filewriter_t* filewriter);
static bool fnames_conf_init(fnames_conf_t* fn, int argc, char* argv[]); static bool fnames_conf_init(fnames_conf_t* fn, int argc, char* argv[]);
static void fnames_conf_done(fnames_conf_t* fn); static void fnames_conf_done(fnames_conf_t* fn);
static void fnames_conf_free_memory(fnames_conf_t* fn); static void fnames_conf_free_memory(fnames_conf_t* fn);
static char* fname_conf_get_prefix(fnames_conf_t* fn);
static char* fname_conf_get_suffix(fnames_conf_t* fn);
static void* thr_filewriter_fun(void* data); static void* thr_filewriter_fun(void* data);
static logfile_t* logmanager_get_logfile(logmanager_t* lm); static logfile_t* logmanager_get_logfile(logmanager_t* lm);
static bool logmanager_register(bool writep); static bool logmanager_register(bool writep);
@ -306,21 +305,6 @@ static int find_last_seqno(strpart_t* parts, int seqno, int seqnoidx);
void flushall_logfiles(bool flush); void flushall_logfiles(bool flush);
bool thr_flushall_check(); bool thr_flushall_check();
const char* get_suffix_default(void)
{
return ".log";
}
const char* get_err_prefix_default(void)
{
return "error";
}
const char* get_err_suffix_default(void)
{
return get_suffix_default();
}
const char* get_logpath_default(void) const char* get_logpath_default(void)
{ {
return "/var/log/maxscale"; return "/var/log/maxscale";
@ -1710,8 +1694,6 @@ static bool fnames_conf_init(fnames_conf_t* fn,
bool succp = false; bool succp = false;
const char* argstr = const char* argstr =
"-h - help\n" "-h - help\n"
"-g <error prefix> ............(\"skygw_err\")\n"
"-i <error suffix> ............(\".log\")\n"
"-j <log path> ............(\"/tmp\")\n" "-j <log path> ............(\"/tmp\")\n"
"-l <syslog log file ids> .......(no default)\n" "-l <syslog log file ids> .......(no default)\n"
"-m <syslog ident> ............(argv[0])\n" "-m <syslog ident> ............(argv[0])\n"
@ -1727,7 +1709,7 @@ static bool fnames_conf_init(fnames_conf_t* fn,
fn->fn_chk_tail = CHK_NUM_FNAMES; fn->fn_chk_tail = CHK_NUM_FNAMES;
#endif #endif
optind = 1; /**<! reset getopt index */ optind = 1; /**<! reset getopt index */
while ((opt = getopt(argc, argv, "+g:h:i:j:l:m:s:o")) != -1) while ((opt = getopt(argc, argv, "+h:j:l:m:s:o")) != -1)
{ {
switch (opt) switch (opt)
{ {
@ -1735,14 +1717,6 @@ static bool fnames_conf_init(fnames_conf_t* fn,
use_stdout = 1; use_stdout = 1;
break; break;
case 'g':
fn->fn_err_prefix = strndup(optarg, MAX_PREFIXLEN);
break;
case 'i':
fn->fn_err_suffix = strndup(optarg, MAX_SUFFIXLEN);
break;
case 'j': case 'j':
fn->fn_logpath = strndup(optarg, MAX_PATHLEN); fn->fn_logpath = strndup(optarg, MAX_PATHLEN);
break; break;
@ -1778,12 +1752,7 @@ static bool fnames_conf_init(fnames_conf_t* fn,
} /** switch (opt) */ } /** switch (opt) */
} }
/** If log file name is not specified in call arguments, use default. */ /** If log file name is not specified in call arguments, use default. */
fn->fn_err_prefix = (fn->fn_err_prefix == NULL) ? fn->fn_logpath = (fn->fn_logpath == NULL) ? strdup(get_logpath_default()) : fn->fn_logpath;
strdup(get_err_prefix_default()) : fn->fn_err_prefix;
fn->fn_err_suffix = (fn->fn_err_suffix == NULL) ?
strdup(get_err_suffix_default()) : fn->fn_err_suffix;
fn->fn_logpath = (fn->fn_logpath == NULL) ?
strdup(get_logpath_default()) : fn->fn_logpath;
/** Set identity string for syslog if it is not set in config.*/ /** Set identity string for syslog if it is not set in config.*/
if (do_syslog) if (do_syslog)
@ -1801,22 +1770,10 @@ static bool fnames_conf_init(fnames_conf_t* fn,
ss_dfprintf(stderr, "\n");*/ ss_dfprintf(stderr, "\n");*/
#if defined(NOT_USED) #if defined(NOT_USED)
fprintf(stderr, fprintf(stderr,
"Error log :\t%s/%s1%s\n" "Log :\t%s/%s1%s\n\n",
"Message log :\t%s/%s1%s\n"
"Trace log :\t%s/%s1%s\n"
"Debug log :\t%s/%s1%s\n\n",
fn->fn_logpath, fn->fn_logpath,
fn->fn_err_prefix, LOGFILE_NAME_PREFIX,
fn->fn_err_suffix, LOGFILE_NAME_SUFFIX);
fn->fn_logpath,
fn->fn_msg_prefix,
fn->fn_msg_suffix,
fn->fn_logpath,
fn->fn_trace_prefix,
fn->fn_trace_suffix,
fn->fn_logpath,
fn->fn_debug_prefix,
fn->fn_debug_suffix);
#endif #endif
succp = true; succp = true;
fn->fn_state = RUN; fn->fn_state = RUN;
@ -1832,19 +1789,6 @@ return_conf_init:
} }
static char* fname_conf_get_prefix(fnames_conf_t* fn)
{
CHK_FNAMES_CONF(fn);
return strdup(fn->fn_err_prefix);
}
static char* fname_conf_get_suffix(fnames_conf_t* fn)
{
CHK_FNAMES_CONF(fn);
return strdup(fn->fn_err_suffix);
}
/** /**
* @node Calls logfile initializer for each logfile. * @node Calls logfile initializer for each logfile.
* *
@ -2152,7 +2096,7 @@ static char* form_full_file_name(strpart_t* parts, logfile_t* lf, int seqnoidx)
{ {
int file_sn; int file_sn;
int link_sn = 0; int link_sn = 0;
char* tmp = parts[0].sp_string; const char* tmp = parts[0].sp_string;
file_sn = find_last_seqno(parts, lf->lf_name_seqno, seqnoidx); file_sn = find_last_seqno(parts, lf->lf_name_seqno, seqnoidx);
@ -2403,8 +2347,8 @@ static bool logfile_init(logfile_t* logfile,
logfile->lf_chk_tail = CHK_NUM_LOGFILE; logfile->lf_chk_tail = CHK_NUM_LOGFILE;
#endif #endif
logfile->lf_logmes = logmanager->lm_logmes; logfile->lf_logmes = logmanager->lm_logmes;
logfile->lf_name_prefix = fname_conf_get_prefix(fn); logfile->lf_name_prefix = LOGFILE_NAME_PREFIX;
logfile->lf_name_suffix = fname_conf_get_suffix(fn); logfile->lf_name_suffix = LOGFILE_NAME_SUFFIX;
logfile->lf_npending_writes = 0; logfile->lf_npending_writes = 0;
logfile->lf_name_seqno = 1; logfile->lf_name_seqno = 1;
logfile->lf_lmgr = logmanager; logfile->lf_lmgr = logmanager;
@ -2544,13 +2488,10 @@ static void logfile_done(logfile_t* lf)
} }
} }
static void logfile_free_memory( static void logfile_free_memory(logfile_t* lf)
logfile_t* lf)
{ {
if (lf->lf_filepath != NULL) free(lf->lf_filepath); if (lf->lf_filepath != NULL) free(lf->lf_filepath);
if (lf->lf_linkpath != NULL) free(lf->lf_linkpath); if (lf->lf_linkpath != NULL) free(lf->lf_linkpath);
if (lf->lf_name_prefix != NULL) free(lf->lf_name_prefix);
if (lf->lf_name_suffix != NULL) free(lf->lf_name_suffix);
if (lf->lf_full_link_name != NULL) free(lf->lf_full_link_name); if (lf->lf_full_link_name != NULL) free(lf->lf_full_link_name);
if (lf->lf_full_file_name != NULL) free(lf->lf_full_file_name); if (lf->lf_full_file_name != NULL) free(lf->lf_full_file_name);
} }
@ -2918,8 +2859,6 @@ static void fnames_conf_done(fnames_conf_t* fn)
static void fnames_conf_free_memory(fnames_conf_t* fn) static void fnames_conf_free_memory(fnames_conf_t* fn)
{ {
free(fn->fn_err_prefix);
free(fn->fn_err_suffix);
free(fn->fn_logpath); free(fn->fn_logpath);
} }

View File

@ -174,8 +174,6 @@ int skygw_log_get_augmentation();
EXTERN_C_BLOCK_END EXTERN_C_BLOCK_END
const char* get_err_prefix_default(void);
const char* get_err_suffix_default(void);
const char* get_logpath_default(void); const char* get_logpath_default(void);
/** /**