[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-httpd-dev
Subject:    [PATCH] LogRoot directive
From:       <unknown () riverstyx ! net>
Date:       1999-03-31 13:40:42
[Download RAW message or body]

DESCRIPTION
------------

this is a pretty simple little patch, but it's something that's bugged me
for over a year now.  i've tested it pretty thoroughly, and i've patched
mod_log_config, mod_log_referer, mod_log_agent, and http_log, so all the
logging should be fine.  

there's a new global variable (ap_log_root) that contains the log root
directory, and a function abstract (ap_log_root_relative()) that mimics
ap_server_root_relative().  ap_log_root is set to ap_server_root + "/logs"
if ap_log_root is empty when ServerRoot is processed.

the patch is against apache 1.3.6.

---
tani hosokawa
river styx internet


["logroot-diffs" (TEXT/PLAIN)]

*** /usr/local/apache_1.3.6/src/main/http_main.c	Wed Mar 17 15:05:43 1999
--- main/http_main.c	Wed Mar 31 03:10:31 1999
***************
*** 278,283 ****
--- 278,284 ----
  static listen_rec *head_listener;
  
  API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN];
+ API_VAR_EXPORT char ap_log_root[MAX_STRING_LEN];
  char ap_server_confname[MAX_STRING_LEN];
  char ap_coredump_dir[MAX_STRING_LEN];
  
*** /usr/local/apache_1.3.6/src/main/http_core.c	Fri Mar 19 15:54:08 1999
--- main/http_core.c	Wed Mar 31 05:32:30 1999
***************
*** 1941,1946 ****
--- 1941,1964 ----
      return NULL;
  }
  
+ static const char *set_log_root(cmd_parms *cmd, void *dummy, char *arg) 
+ {
+     const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+ 
+     if (err != NULL) {
+         return err;
+     }
+ 
+     arg = ap_os_canonical_filename(cmd->pool, arg);
+ 
+     if (!ap_is_directory(arg)) {
+         return "LogRoot must be a valid directory";
+     }
+     ap_cpystrn(ap_log_root, arg,
+ 	       sizeof(ap_log_root));
+     return NULL;
+ }
+ 
  static const char *set_server_root(cmd_parms *cmd, void *dummy, char *arg) 
  {
      const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
***************
*** 1956,1961 ****
--- 1974,1985 ----
      }
      ap_cpystrn(ap_server_root, arg,
  	       sizeof(ap_server_root));
+ // if ap_log_root isn't defined yet, default it to ap_server_root + "/logs"
+     if (!strcmp(ap_log_root,"")) {
+        ap_cpystrn(ap_log_root, arg,
+                sizeof(ap_log_root));
+        strncat (ap_log_root, "/logs", 5);
+     }
      return NULL;
  }
  
***************
*** 2761,2766 ****
--- 2785,2792 ----
    "En-/disable server signature (on|off|email)" },
  { "ServerRoot", set_server_root, NULL, RSRC_CONF, TAKE1,
    "Common directory of server-related files (logs, confs, etc.)" },
+ { "LogRoot", set_log_root, NULL, RSRC_CONF, TAKE1,
+   "Sets the log root directory (defaults to ServerRoot)" },
  { "ErrorLog", set_server_string_slot,
    (void *)XtOffsetOf (server_rec, error_fname), RSRC_CONF, TAKE1,
    "The filename of the error log" },
*** /usr/local/apache_1.3.6/src/main/http_log.c	Thu Mar 11 08:52:38 1999
--- main/http_log.c	Wed Mar 31 03:32:28 1999
***************
*** 221,227 ****
      }
  #endif
      else {
! 	fname = ap_server_root_relative(p, s->error_fname);
          if (!(s->error_log = ap_pfopen(p, fname, "a"))) {
              perror("fopen");
              fprintf(stderr, "%s: could not open error log file %s.\n",
--- 221,227 ----
      }
  #endif
      else {
! 	fname = ap_log_root_relative(p, s->error_fname);
          if (!(s->error_log = ap_pfopen(p, fname, "a"))) {
              perror("fopen");
              fprintf(stderr, "%s: could not open error log file %s.\n",
***************
*** 473,479 ****
      if (!fname) 
  	return;
  
!     fname = ap_server_root_relative(p, fname);
      mypid = getpid();
      if (mypid != saved_pid && stat(fname, &finfo) == 0) {
        /* USR1 and HUP call this on each restart.
--- 473,479 ----
      if (!fname) 
  	return;
  
!     fname = ap_log_root_relative(p, fname);
      mypid = getpid();
      if (mypid != saved_pid && stat(fname, &finfo) == 0) {
        /* USR1 and HUP call this on each restart.
*** /usr/local/apache_1.3.6/src/include/http_conf_globals.h	Fri Jan  1 11:04:39 1999
--- include/http_conf_globals.h	Wed Mar 31 03:18:14 1999
***************
*** 101,106 ****
--- 101,107 ----
   */
  
  extern API_VAR_EXPORT char ap_server_root[MAX_STRING_LEN];
+ extern API_VAR_EXPORT char ap_log_root[MAX_STRING_LEN];
  extern char ap_server_confname[MAX_STRING_LEN];
  
  /* for -C, -c and -D switches */
*** /usr/local/apache_1.3.6/src/modules/standard/mod_log_agent.c	Fri Jan  1 11:05:10 1999
--- modules/standard/mod_log_agent.c	Wed Mar 31 03:30:31 1999
***************
*** 107,113 ****
      agent_log_state *cls = ap_get_module_config(s->module_config,
                                               &agent_log_module);
  
!     char *fname = ap_server_root_relative(p, cls->fname);
  
      if (cls->agent_fd > 0)
          return;                 /* virtual log shared w/main server */
--- 107,113 ----
      agent_log_state *cls = ap_get_module_config(s->module_config,
                                               &agent_log_module);
  
!     char *fname = ap_log_root_relative(p, cls->fname);
  
      if (cls->agent_fd > 0)
          return;                 /* virtual log shared w/main server */
*** /usr/local/apache_1.3.6/src/modules/standard/mod_log_referer.c	Fri Jan  1 11:05:11 1999
--- modules/standard/mod_log_referer.c	Wed Mar 31 03:30:12 1999
***************
*** 123,129 ****
      referer_log_state *cls = ap_get_module_config(s->module_config,
                                                 &referer_log_module);
  
!     char *fname = ap_server_root_relative(p, cls->fname);
  
      if (cls->referer_fd > 0)
          return;                 /* virtual log shared w/main server */
--- 123,129 ----
      referer_log_state *cls = ap_get_module_config(s->module_config,
                                                 &referer_log_module);
  
!     char *fname = ap_log_root_relative(p, cls->fname);
  
      if (cls->referer_fd > 0)
          return;                 /* virtual log shared w/main server */
*** /usr/local/apache_1.3.6/src/modules/standard/mod_log_config.c	Thu Mar  4 11:28:40 1999
--- modules/standard/mod_log_config.c	Wed Mar 31 03:21:02 1999
***************
*** 992,998 ****
          cls->log_fd = ap_piped_log_write_fd(pl);
      }
      else {
!         char *fname = ap_server_root_relative(p, cls->fname);
          if ((cls->log_fd = ap_popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
              ap_log_error(APLOG_MARK, APLOG_ERR, s,
                           "could not open transfer log file %s.", fname);
--- 992,998 ----
          cls->log_fd = ap_piped_log_write_fd(pl);
      }
      else {
!         char *fname = ap_log_root_relative(p, cls->fname);
          if ((cls->log_fd = ap_popenf(p, fname, xfer_flags, xfer_mode)) < 0) {
              ap_log_error(APLOG_MARK, APLOG_ERR, s,
                           "could not open transfer log file %s.", fname);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic