So here's a first rough draft at a new libsvn_repos logging API, just
to get things rolling.  Let the dart-throwing begin.
Here are my design principles:
    * the API should be shareable by both svnserve and mod_dav_svn, or
      really, *any* process using libsvn_repos.
    * logging is a feature of the repository object.  My plan is to
      extend svn_repos_t to contain new runtime variables that point to
      logfiles.  Callers of svn_repos_t have accessors to get/set these
      variables.
    * the API should allow the process to identify itself in the log.
      That way we can tell if the log-entry was written by apache, by
      svnserve, or even a client using direct access.
    * as Branko pointed out earlier, network requests should -not- be
      mixed with debugging logs.  So I've decided to follow apache's
      model:  an "accesslog" for network requests, and an "errorlog" to
      hold both errors and debug-messages, based on the repository's
      current "log-level".
    * I've tried to keep the API as minimal as can be (KISS).  Notice
      that while there are only three log-levels in the enumerated type
      right now, they're spread out enough to add more levels later on.
Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h      (revision 15339)
+++ subversion/include/svn_repos.h      (working copy)
@@ -1702,6 +1702,132 @@
                                svn_boolean_t *access_granted,
                                apr_pool_t *pool);
+
+
+/* ---------------------------------------------------------------*/
+
+/**
+ * @defgroup svn_repos_logging Repository logging subsystem
+ * @{
+ *
+ * @since New in 1.3.
+ */
+
+/** The different "levels" of messages that can go into a repository's
+    errorlog. */
+typedef enum
+{
+  /** A real error happened */
+  svn_repos_loglevel_error = 1,
+
+  /** No error, but something that might be of concern */
+  svn_repos_loglevel_warning = 5,
+
+  /** Message only interesting to svn developers  */
+  svn_repos_loglevel_debug = 10
+
+} svn_repos_loglevel_t;
+
+
+/** Accessors for repository's logfiles and loglevel.  These things
+ *  are set at runtime by the server (in something like svnserve.conf
+ *  or httpd.conf).
+ */
+
+/** Set the error-logging threshold of @repos to @loglevel.  Use @a
+    pool for temporary memory allocation. */
+svn_error_t *
+svn_repos_set_loglevel (svn_repos_t *repos,
+                        svn_repos_loglevel_t loglevel,
+                        apr_pool_t *pool);
+
+/** Set @a *loglevel to the repository's current error-logging
+    threshold.  Use @a pool for temporary memory allocation.  */
+svn_error_t *
+svn_repos_get_loglevel (svn_repos_loglevel_t *loglevel,
+                        svn_repos_t *repos,
+                        apr_pool_t *pool);
+
+/** Have @a repos write all errorlog messages to @a logfile.  Use @a
+    pool for temporary memory allocation.  */
+svn_error_t *
+svn_repos_set_errorlog (svn_repos_t *repos,
+                        apr_file_t *logfile,
+                        apr_pool_t *pool);
+
+/** Set @a *logfile to the current errorlog of @a repos.  Use @a pool
+    for temporary memory allocation. */
+svn_error_t *
+svn_repos_get_errorlog (apr_file_t **logfile,
+                        svn_repos_t *repos,
+                        apr_pool_t *pool);
+
+/** Have @a repos write all accesslog messages to @a logfile.  Use @a
+    pool for temporary memory allocation. */
+svn_error_t *
+svn_repos_set_accesslog (svn_repos_t *repos,
+                         apr_file_t *logfile,
+                         apr_pool_t *pool);
+
+/** Set @a *logfile to the current accesslog of @a repos.  Use @a pool
+    for temporary memory allocation. */
+svn_error_t *
+svn_repos_get_accesslog (apr_file_t **logfile,
+                         svn_repos_t *repos,
+                         apr_pool_t *pool);
+
+
+/** Write @a message into the accesslog of @a repos.  If not @c NULL,
+ * then also include the following information in the log entry:
+ *
+ *   @a process_name  :  the name of the process using libsvn_repos.
+ *                       (if @c NULL, write "(unknown process)").
+ *   @a sockaddr      :  the IP address of the incoming request.
+ *                       (if @c NULL, write "(unknown IP)").
+ *   @a username      :  the authenticated username attached to the  
request.
+ *                       (if @c NULL, write "(unknown user)").
+ *
+ * Use @a pool for temporary memory allocation.
+ */
+svn_error_t *
+svn_repos_write_accesslog (svn_repos_t *repos,
+                           const char *process_name,
+                           apr_sockaddr_t *sockaddr,
+                           const char *username,
+                           const char *message,
+                           apr_pool_t *pool);
+
+
+/** Write @a message into the errorlog of @a repos, if and only if the
+ * current loglevel of @a repos is greater than or equal to @a
+ * loglevel (see @c svn_repos_set_loglevel).  If not @c NULL, then
+ * also include the following information in the log entry:
+ *
+ *   @a process_name  :  the name of the process using libsvn_repos.
+ *                       (if @c NULL, write "(unknown process)").
+ *
+ * Use @a pool for temporary memory allocation.
+ */
+svn_error_t *
+svn_repos_write_errorlog (svn_repos_t *repos,
+                          const char *process_name,
+                          svn_repos_loglevel_t loglevel,
+                          const char *message,
+                          apr_pool_t *pool);
+
+/** Convience function:  same as @c svn_repos_write_errorlog, but
+ * automatically write @a err->message at level @c  
svn_repos_loglevel_error.
+ */
+svn_error_t *
+svn_repos_write_errorlog_error (svn_repos_t *repos,
+                                const char *process_name,
+                                svn_error_t *err,
+                                apr_pool_t *pool);
+
+
+/** @} */
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Fri Jul 15 02:50:59 2005