[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

logging: mod_dav_svn proof of concept

From: Ben Collins-Sussman <sussman_at_collab.net>
Date: 2005-08-09 03:25:27 CEST

It turned out to be amazingly easy to make mod_dav_svn log 'high
level' actions to a separate logfile. It's all being done by httpd
for us.

1. When appropriate, have mod_dav_svn set the SVN-ACTION environment
variable within a request object. (See patch below.)

2. To log these actions in a private file, simply add this line to
httpd.conf:

       CustomLog logs/svn_log "%u \"%{SVN-ACTION}e\" %t" env=SVN-ACTION

Here's some sample output. (Yes, it's primitive, but admins can
change the format string above to write any number of fields in any
order. Thank you, Apache 2.0)

$ tail -f /usr/local/apache2/logs/svn_log
powerguy "log" [08/Aug/2005:17:33:09 -0500]
powerguy "update" [08/Aug/2005:17:33:28 -0500]
powerguy "log" [08/Aug/2005:17:33:41 -0500]
powerguy "lock" [08/Aug/2005:17:33:52 -0500]
powerguy "unlock" [08/Aug/2005:17:33:56 -0500]
powerguy "blame" [08/Aug/2005:17:35:40 -0500]

Here's the patch I've been using so far. Stay tuned for more mails
regarding how to decipher particular actions. All I've done below is
is isolate the really easy ones.

----------------------------

[[[
Begin adding "high-level" logging to mod_dav_svn.

When appropriate, have mod_dav_svn set the SVN-ACTION environment
variable on particular request objects. Administrators can then have
these actions written to a separate logfile by adding this line to
httpd.conf:

   CustomLog logs/svn_log "%t %u \"%{SVN-ACTION}e\"" env=SVN-ACTION

* subversion/mod_dav_svn/version.c
   (dav_svn_merge): set SVN-ACTION to 'commit'.

* subversion/mod_dav_svn/log.c
   (dav_svn__log_report): set SVN-ACTION to 'log'.

* subversion/mod_dav_svn/file_revs.c
   (dav_svn__file_revs_report): set SVN-ACTION to 'blame'.

* subversion/mod_dav_svn/lock.c
   (dav_svn_append_locks): set SVN-ACTION to 'lock'.
   (dav_svn_remove_lock): set SVN-ACTION to 'unlock'.

* subversion/mod_dav_svn/update.c
   (dav_svn__update_report): set SVN-ACTION to 'update', though this
                               needs to get more specific later on.

]]]

Index: subversion/mod_dav_svn/file_revs.c
===================================================================
--- subversion/mod_dav_svn/file_revs.c (revision 15593)
+++ subversion/mod_dav_svn/file_revs.c (working copy)
@@ -215,6 +215,10 @@
    arb.r = resource->info->r;
    arb.repos = resource->info->repos;
+ /* We've detected a 'high level' svn action to log. */
+ apr_table_setn(resource->info->r->subprocess_env,
+ "SVN-ACTION", "blame");
+
    /* Sanity check. */
    ns = dav_svn_find_ns(doc->namespaces, SVN_XML_NAMESPACE);
    /* ### This is done on other places, but the document element is
Index: subversion/mod_dav_svn/log.c
===================================================================
--- subversion/mod_dav_svn/log.c (revision 15593)
+++ subversion/mod_dav_svn/log.c (working copy)
@@ -219,6 +219,10 @@
    apr_array_header_t *paths
      = apr_array_make(resource->pool, 0, sizeof(const char *));
+ /* We've detected a 'high level' svn action to log. */
+ apr_table_setn(resource->info->r->subprocess_env,
+ "SVN-ACTION", "log");
+
    /* Sanity check. */
    ns = dav_svn_find_ns(doc->namespaces, SVN_XML_NAMESPACE);
    if (ns == -1)
Index: subversion/mod_dav_svn/update.c
===================================================================
--- subversion/mod_dav_svn/update.c (revision 15593)
+++ subversion/mod_dav_svn/update.c (working copy)
@@ -1364,6 +1364,12 @@
            }
        }
+
+ /* ### Temporary placeholder for now: really, this could be any of
+ {checkout, update, export, switch, status, diff, merge}. */
+ apr_table_setn(resource->info->r->subprocess_env,
+ "SVN-ACTION", "update");
+
    /* this will complete the report, and then drive our editor to
generate
       the response to the client. */
    serr = svn_repos_finish_report(rbaton, resource->pool);
Index: subversion/mod_dav_svn/version.c
===================================================================
--- subversion/mod_dav_svn/version.c (revision 15593)
+++ subversion/mod_dav_svn/version.c (working copy)
@@ -1635,6 +1635,10 @@
                                      SVN_DAV_ERROR_TAG);
      }

+ /* We've detected a 'high level' svn action to log. */
+ apr_table_setn(target->info->r->subprocess_env,
+ "SVN-ACTION", "commit");
+
    /* Before attempting the final commit, we need to push any incoming
       lock-tokens into the filesystem's access_t. Normally they come
       in via 'If:' header, and dav_svn_get_resource() automatically
Index: subversion/mod_dav_svn/lock.c
===================================================================
--- subversion/mod_dav_svn/lock.c (revision 15593)
+++ subversion/mod_dav_svn/lock.c (working copy)
@@ -730,6 +730,10 @@
                           DAV_ERR_LOCK_SAVE_LOCK,
                           "Tried to attach multiple locks to a
resource.");
+ /* We've detected a 'high level' svn action to log. */
+ apr_table_setn(resource->info->r->subprocess_env,
+ "SVN-ACTION", "lock");
+
    /* RFC2518bis (section 7.4) doesn't require us to support
       'lock-null' resources at all. Instead, it asks that we treat
       'LOCK nonexistentURL' as a PUT (followed by a LOCK) of a 0-
byte file. */
@@ -888,6 +892,10 @@
                           DAV_ERR_LOCK_SAVE_LOCK,
                           "Path is not accessible.");
+ /* We've detected a 'high level' svn action to log. */
+ apr_table_setn(resource->info->r->subprocess_env,
+ "SVN-ACTION", "unlock");
+
    if (locktoken == NULL)
      {
        /* Need to manually discover any lock on the resource. */

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Tue Aug 9 03:26:29 2005

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.