You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2013/12/14 22:51:18 UTC
[09/50] git commit: TS-2401: Remove global system_log_dir
TS-2401: Remove global system_log_dir
In the 2 places that actually look at this, we implement the
predictable semantics of using proxy.config.log.logfile_dir (relative
to $PREFIX) if it is specified. Otherwise we use the compile-time
log directory. In either case, we never fall back to different
directories. We either use the one specified by the operator or
fail loudly and suddenly.
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/88f51768
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/88f51768
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/88f51768
Branch: refs/heads/5.0.x
Commit: 88f51768941ea440a19d8ff9ee5ef8907b72b782
Parents: bdd7af5
Author: James Peach <jp...@apache.org>
Authored: Wed Nov 27 15:51:49 2013 -0800
Committer: James Peach <jp...@apache.org>
Committed: Thu Dec 5 20:33:49 2013 -0800
----------------------------------------------------------------------
example/app-template/app-template.cc | 2 --
lib/records/I_RecDefs.h | 1 -
mgmt/Main.cc | 9 --------
proxy/Initialize.cc | 2 +-
proxy/Main.cc | 13 -----------
proxy/logging/LogConfig.cc | 24 +++++++++-----------
proxy/logging/LogStandalone.cc | 1 -
proxy/sac.cc | 8 -------
proxy/shared/DiagsConfig.cc | 37 ++++++++++++++++++-------------
9 files changed, 32 insertions(+), 65 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/example/app-template/app-template.cc
----------------------------------------------------------------------
diff --git a/example/app-template/app-template.cc b/example/app-template/app-template.cc
index fefff13..5f8cb6d 100644
--- a/example/app-template/app-template.cc
+++ b/example/app-template/app-template.cc
@@ -55,7 +55,6 @@ int system_num_of_udp_threads = DEFAULT_NUMBER_OF_UDP_THREADS;
char system_runtime_dir[PATH_NAME_MAX + 1];
char system_config_directory[PATH_NAME_MAX + 1];
-char system_log_dir[PATH_NAME_MAX + 1];
//int system_remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
@@ -159,7 +158,6 @@ int main(int argc, char * argv[])
// Get TS directories
ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, sizeof(system_config_directory));
ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, sizeof(system_runtime_dir));
- ink_strlcpy(system_log_dir, Layout::get()->logdir, sizeof(system_log_dir));
if (chdir(Layout::get()->prefix) < 0) {
fprintf(stderr,"unable to change to root directory \"%s\" [%d '%s']\n", Layout::get()->prefix, errno, strerror(errno));
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/lib/records/I_RecDefs.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecDefs.h b/lib/records/I_RecDefs.h
index 4517357..302b3c9 100644
--- a/lib/records/I_RecDefs.h
+++ b/lib/records/I_RecDefs.h
@@ -179,6 +179,5 @@ typedef int (*RecRawStatSyncCb) (const char *name, RecDataT data_type, RecData *
// System Defaults
extern char system_runtime_dir[PATH_NAME_MAX + 1];
extern char system_config_directory[PATH_NAME_MAX + 1];
-extern char system_log_dir[PATH_NAME_MAX + 1];
#endif
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/mgmt/Main.cc
----------------------------------------------------------------------
diff --git a/mgmt/Main.cc b/mgmt/Main.cc
index a48686b..c8e1a33 100644
--- a/mgmt/Main.cc
+++ b/mgmt/Main.cc
@@ -80,7 +80,6 @@ static bool proxy_on = true;
// TODO: Check if really need those
char system_runtime_dir[PATH_NAME_MAX + 1];
char system_config_directory[PATH_NAME_MAX + 1];
-char system_log_dir[PATH_NAME_MAX + 1];
char mgmt_path[PATH_NAME_MAX + 1];
@@ -287,14 +286,6 @@ init_dirs()
mgmt_elog(0, "please set 'proxy.config.local_state_dir'\n");
_exit(1);
}
-
- REC_ReadConfigString(buf, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
- Layout::get()->relative(system_log_dir, PATH_NAME_MAX, buf);
- if (access(system_log_dir, W_OK) == -1) {
- mgmt_elog(0, "unable to access() log dir'%s': %d, %s\n", system_log_dir, errno, strerror(errno));
- mgmt_elog(0, "please set 'proxy.config.log.logfile_dir'\n");
- _exit(1);
- }
}
static void
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/Initialize.cc
----------------------------------------------------------------------
diff --git a/proxy/Initialize.cc b/proxy/Initialize.cc
index be296b2..54026ba 100644
--- a/proxy/Initialize.cc
+++ b/proxy/Initialize.cc
@@ -276,7 +276,7 @@ init_system_diags(char *bdt, char *bat)
char diags_logpath[PATH_NAME_MAX + 1];
ink_filepath_make(diags_logpath, sizeof(diags_logpath),
- system_log_dir, DIAGS_LOG_FILE);
+ Layout::get()->logdir, DIAGS_LOG_FILE);
diags_log_fp = fopen(diags_logpath, "w");
if (diags_log_fp) {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/Main.cc
----------------------------------------------------------------------
diff --git a/proxy/Main.cc b/proxy/Main.cc
index 3b7e6ae..ec75cef 100644
--- a/proxy/Main.cc
+++ b/proxy/Main.cc
@@ -146,7 +146,6 @@ int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG;
char system_runtime_dir[PATH_NAME_MAX + 1]; // Layout->runtimedir
char system_config_directory[PATH_NAME_MAX + 1]; // Layout->sysconfdir
-char system_log_dir[PATH_NAME_MAX + 1]; // Layout->logdir
static char error_tags[1024] = "";
static char action_tags[1024] = "";
@@ -288,7 +287,6 @@ init_dirs(void)
ink_strlcpy(system_config_directory, Layout::get()->sysconfdir, PATH_NAME_MAX);
ink_strlcpy(system_runtime_dir, Layout::get()->runtimedir, PATH_NAME_MAX);
- ink_strlcpy(system_log_dir, Layout::get()->logdir, PATH_NAME_MAX);
/*
* XXX: There is not much sense in the following code
@@ -318,17 +316,6 @@ init_dirs(void)
}
}
- if (access(system_log_dir, W_OK) == -1) {
- REC_ReadConfigString(buf, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
- Layout::get()->relative(system_log_dir, PATH_NAME_MAX, buf);
- if (access(system_log_dir, W_OK) == -1) {
- fprintf(stderr,"unable to access() log dir'%s':%d, %s\n",
- system_log_dir, errno, strerror(errno));
- fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
- _exit(1);
- }
- }
-
}
//
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/logging/LogConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogConfig.cc b/proxy/logging/LogConfig.cc
index c411336..6cb8e68 100644
--- a/proxy/logging/LogConfig.cc
+++ b/proxy/logging/LogConfig.cc
@@ -66,8 +66,6 @@
#define PARTITION_HEADROOM_MB 10
-char *ink_prepare_dir(char *logfile_dir);
-
void
LogConfig::setup_default_values()
{
@@ -248,20 +246,18 @@ LogConfig::read_configuration_variables()
// Make it relative from Layout
logfile_dir = Layout::get()->relative(ptr);
ats_free(ptr);
- if (access(logfile_dir, W_OK) == -1) {
- ats_free(logfile_dir);
- logfile_dir = NULL;
- if (access(system_log_dir, W_OK) == -1) {
- // Try 'system_root_dir/var/log/trafficserver' directory
- fprintf(stderr,"unable to access() log dir'%s': %d, %s\n",
- system_log_dir, errno, strerror(errno));
- fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
- _exit(1);
- }
- logfile_dir = ats_strdup(system_log_dir);
- }
+ } else {
+ ats_free(logfile_dir);
+ logfile_dir = ats_strdup(Layout::get()->logdir);
}
+ if (access(logfile_dir, R_OK | W_OK | X_OK) == -1) {
+ // Try 'system_root_dir/var/log/trafficserver' directory
+ fprintf(stderr,"unable to access log directory '%s': %d, %s\n",
+ logfile_dir, errno, strerror(errno));
+ fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
+ _exit(1);
+ }
//
// for each predefined logging format, we need to know:
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/logging/LogStandalone.cc
----------------------------------------------------------------------
diff --git a/proxy/logging/LogStandalone.cc b/proxy/logging/LogStandalone.cc
index 17fd687..5bf3b6f 100644
--- a/proxy/logging/LogStandalone.cc
+++ b/proxy/logging/LogStandalone.cc
@@ -58,7 +58,6 @@ char proxy_name[MAXDNAME + 1] = "unknown";
char system_config_directory[PATH_NAME_MAX + 1] = "";
char system_runtime_dir[PATH_NAME_MAX + 1] = "";
-char system_log_dir[PATH_NAME_MAX + 1] = "";
char error_tags[1024] = "";
char action_tags[1024] = "";
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/sac.cc
----------------------------------------------------------------------
diff --git a/proxy/sac.cc b/proxy/sac.cc
index f094e04..e150507 100644
--- a/proxy/sac.cc
+++ b/proxy/sac.cc
@@ -89,14 +89,6 @@ main(int /* argc ATS_UNUSED */, char *argv[])
snprintf(configDirectoryType, sizeof(configDirectoryType), "S%d", PATH_NAME_MAX - 1);
process_args(argument_descriptions, countof(argument_descriptions), argv);
- // Get log directory
- ink_strlcpy(system_log_dir, Layout::get()->logdir, sizeof(system_log_dir));
- if (access(system_log_dir, R_OK) == -1) {
- fprintf(stderr, "unable to change to log directory \"%s\" [%d '%s']\n", system_log_dir, errno, strerror(errno));
- fprintf(stderr, " please set correct path in env variable TS_ROOT \n");
- exit(1);
- }
-
// check for the version number request
//
if (version_flag) {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/88f51768/proxy/shared/DiagsConfig.cc
----------------------------------------------------------------------
diff --git a/proxy/shared/DiagsConfig.cc b/proxy/shared/DiagsConfig.cc
index 53af04c..27ec46b 100644
--- a/proxy/shared/DiagsConfig.cc
+++ b/proxy/shared/DiagsConfig.cc
@@ -288,6 +288,8 @@ DiagsConfig::RegisterDiagConfig()
DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
{
char diags_logpath[PATH_NAME_MAX + 1];
+ xptr<char> logpath;
+
callbacks_established = false;
diags_log_fp = (FILE *) NULL;
diags = NULL;
@@ -303,23 +305,26 @@ DiagsConfig::DiagsConfig(char *bdt, char *bat, bool use_records)
config_diags_norecords();
return;
}
- ////////////////////////
- // open the diags log //
- ////////////////////////
-
- if (access(system_log_dir, R_OK) == -1) {
- REC_ReadConfigString(diags_logpath, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
- Layout::get()->relative(system_log_dir, PATH_NAME_MAX, diags_logpath);
-
- if (access(system_log_dir, R_OK) == -1) {
- fprintf(stderr,"unable to access() log dir'%s': %d, %s\n",
- system_log_dir, errno, strerror(errno));
- fprintf(stderr,"please set 'proxy.config.log.logfile_dir'\n");
- _exit(1);
- }
+
+ // Open the diagnostics log. If proxy.config.log.logfile_dir is set use that, otherwise fall
+ // back to the configured log directory.
+
+ diags_logpath[0] = '\0';
+ REC_ReadConfigString(diags_logpath, "proxy.config.log.logfile_dir", PATH_NAME_MAX);
+ if (strlen(diags_logpath) > 0) {
+ logpath = Layout::get()->relative(diags_logpath);
+ } else {
+ logpath = ats_strdup(Layout::get()->logdir);
+ }
+
+ if (access(logpath, W_OK | R_OK) == -1) {
+ fprintf(stderr, "unable to access log directory '%s': %d, %s\n",
+ (const char *)logpath, errno, strerror(errno));
+ fprintf(stderr, "please set 'proxy.config.log.logfile_dir'\n");
+ _exit(1);
}
- ink_filepath_make(diags_logpath, sizeof(diags_logpath),
- system_log_dir, DIAGS_LOG_FILE);
+
+ ink_filepath_make(diags_logpath, sizeof(diags_logpath), logpath, DIAGS_LOG_FILE);
// open write append
// diags_log_fp = fopen(diags_logpath,"w");