You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by rb...@covalent.net on 2001/06/03 19:13:16 UTC

New hook.

This patch adds a new hook to the server.  The idea is that it is
important for any real monitoring service to know whenever an error has
been logged.  This can be done by having a process watch the error log,
but then it is harder to find out what kind of error it was, or what the
errno (apr_status_t) value was.

The new hook is called after the error log has been written, so that the
server's error log is effected as little as possible.

If nobody objects, I will commit this later this week.

Ryan

Index: include/http_log.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/http_log.h,v
retrieving revision 1.28
diff -u -d -b -w -u -r1.28 http_log.h
--- include/http_log.h	2001/05/03 23:39:43	1.28
+++ include/http_log.h	2001/06/03 15:38:43
@@ -275,6 +275,11 @@
  */
 #define ap_piped_log_write_fd(pl)	((pl)->fds[1])

+AP_DECLARE_HOOK(void, error_log, (const char *file, int line, int level,
+                       apr_status_t status, const server_rec *s,
+                       const request_rec *r, apr_pool_t *pool,
+                       const char *errstr))
+
 #ifdef __cplusplus
 }
 #endif
Index: server/log.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/log.c,v
retrieving revision 1.92
diff -u -d -b -w -u -r1.92 log.c
--- server/log.c	2001/05/17 12:10:22	1.92
+++ server/log.c	2001/06/03 15:38:50
@@ -96,6 +96,10 @@
 	int	t_val;
 } TRANS;

+APR_HOOK_STRUCT(
+    APR_HOOK_LINK(error_log)
+)
+
 #ifdef HAVE_SYSLOG

 static const TRANS facilities[] = {
@@ -455,6 +459,7 @@
 	syslog(level_and_mask, "%s", errstr);
     }
 #endif
+    ap_run_error_log(file, line, level, status, s, r, pool, errstr);
 }

 AP_DECLARE(void) ap_log_error(const char *file, int line, int level,
@@ -749,4 +754,11 @@
 {
     apr_pool_cleanup_run(pl->p, pl, piped_log_cleanup);
 }
+
+AP_IMPLEMENT_HOOK_VOID(error_log,
+                       (const char *file, int line, int level,
+                       apr_status_t status, const server_rec *s,
+                       const request_rec *r, apr_pool_t *pool,
+                       const char *errstr), (file, line, level,
+                       status, s, r, pool, errstr))



_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------



Re: New hook.

Posted by Jeff Trawick <tr...@bellsouth.net>.
<rb...@covalent.net> writes:

> This patch adds a new hook to the server.  The idea is that it is
> important for any real monitoring service to know whenever an error has
> been logged.  This can be done by having a process watch the error log,
> but then it is harder to find out what kind of error it was, or what the
> errno (apr_status_t) value was.
> 
> The new hook is called after the error log has been written, so that the
> server's error log is effected as little as possible.

+1, don't care what you call it (within reason)

-- 
Jeff Trawick | trawickj@bellsouth.net | PGP public key at web site:
       http://www.geocities.com/SiliconValley/Park/9289/
             Born in Roswell... married an alien...


Re: New hook.

Posted by Bill Stoddard <bi...@wstoddard.com>.
+1

> 
> This patch adds a new hook to the server.  The idea is that it is
> important for any real monitoring service to know whenever an error has
> been logged.  This can be done by having a process watch the error log,
> but then it is harder to find out what kind of error it was, or what the
> errno (apr_status_t) value was.
> 
> The new hook is called after the error log has been written, so that the
> server's error log is effected as little as possible.
> 
> If nobody objects, I will commit this later this week.
> 
> Ryan
> 
> Index: include/http_log.h
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/include/http_log.h,v
> retrieving revision 1.28
> diff -u -d -b -w -u -r1.28 http_log.h
> --- include/http_log.h 2001/05/03 23:39:43 1.28
> +++ include/http_log.h 2001/06/03 15:38:43
> @@ -275,6 +275,11 @@
>   */
>  #define ap_piped_log_write_fd(pl) ((pl)->fds[1])
> 
> +AP_DECLARE_HOOK(void, error_log, (const char *file, int line, int level,
> +                       apr_status_t status, const server_rec *s,
> +                       const request_rec *r, apr_pool_t *pool,
> +                       const char *errstr))
> +
>  #ifdef __cplusplus
>  }
>  #endif
> Index: server/log.c
> ===================================================================
> RCS file: /home/cvs/httpd-2.0/server/log.c,v
> retrieving revision 1.92
> diff -u -d -b -w -u -r1.92 log.c
> --- server/log.c 2001/05/17 12:10:22 1.92
> +++ server/log.c 2001/06/03 15:38:50
> @@ -96,6 +96,10 @@
>   int t_val;
>  } TRANS;
> 
> +APR_HOOK_STRUCT(
> +    APR_HOOK_LINK(error_log)
> +)
> +
>  #ifdef HAVE_SYSLOG
> 
>  static const TRANS facilities[] = {
> @@ -455,6 +459,7 @@
>   syslog(level_and_mask, "%s", errstr);
>      }
>  #endif
> +    ap_run_error_log(file, line, level, status, s, r, pool, errstr);
>  }
> 
>  AP_DECLARE(void) ap_log_error(const char *file, int line, int level,
> @@ -749,4 +754,11 @@
>  {
>      apr_pool_cleanup_run(pl->p, pl, piped_log_cleanup);
>  }
> +
> +AP_IMPLEMENT_HOOK_VOID(error_log,
> +                       (const char *file, int line, int level,
> +                       apr_status_t status, const server_rec *s,
> +                       const request_rec *r, apr_pool_t *pool,
> +                       const char *errstr), (file, line, level,
> +                       status, s, r, pool, errstr))
> 
> 
> 
> _______________________________________________________________________________
> Ryan Bloom                        rbb@apache.org
> 406 29th St.
> San Francisco, CA 94131
> -------------------------------------------------------------------------------
> 
> 


Re: New hook.

Posted by rb...@covalent.net.
On Mon, 4 Jun 2001, Greg Marr wrote:

> At 01:13 PM 06/03/2001, rbb@covalent.net wrote:
> >The new hook is called after the error log has been written, so that
> >the server's error log is effected as little as possible.
>
> >+AP_DECLARE_HOOK(void, error_log,
>
> For clarity, should it be called post_error_log instead of just
> error_log?  This would also help avoid confusion if someone later
> decides they need to add a hook that is called before logging,

That's fine.  Nobody ever likes how I name things, so I am always willing
to change the names.

Ryan
_______________________________________________________________________________
Ryan Bloom                        	rbb@apache.org
406 29th St.
San Francisco, CA 94131
-------------------------------------------------------------------------------


Re: New hook.

Posted by Greg Marr <gr...@alum.wpi.edu>.
At 01:13 PM 06/03/2001, rbb@covalent.net wrote:
>The new hook is called after the error log has been written, so that 
>the server's error log is effected as little as possible.

>+AP_DECLARE_HOOK(void, error_log,

For clarity, should it be called post_error_log instead of just 
error_log?  This would also help avoid confusion if someone later 
decides they need to add a hook that is called before logging,

-- 
Greg Marr
gregm@alum.wpi.edu
"We thought you were dead."
"I was, but I'm better now." - Sheridan, "The Summoning"