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

Re: [PATCH] libsvn_repos logging API -- 2nd draft

From: Ben Collins-Sussman <sussman_at_collab.net>
Date: 2005-07-15 16:59:36 CEST

Okay, here's a 2nd draft of the logging API, based on feedback.

* 'processname' is no longer a parameter, but an internal svn_repos_t
   field with its own accessors.

* accessors no longer return svn_error_t's, nor require pools.

* log-writing APIs no longer return svn_error_t's either, and now take
   svn_stream_t's instead of apr_file_t's.

I'll send a followup mail to discuss some of the other design issues
that have popped up in this thread.

Index: subversion/include/svn_repos.h
===================================================================
--- subversion/include/svn_repos.h (revision 15345)
+++ subversion/include/svn_repos.h (working copy)
@@ -25,6 +25,7 @@
#include <apr_pools.h>
#include <apr_hash.h>
+#include <apr_network_io.h>
#include "svn_fs.h"
#include "svn_delta.h"
#include "svn_types.h"
@@ -1702,6 +1703,133 @@
                                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 @a repos to @a loglevel. */
+void
+svn_repos_set_loglevel (svn_repos_t *repos,
+ svn_repos_loglevel_t loglevel);
+
+/** Set @a *loglevel to the repository's current error-logging
+ threshold, or 0 if not defined. */
+void
+svn_repos_get_loglevel (svn_repos_loglevel_t *loglevel,
+ svn_repos_t *repos);
+
+/** Have @a repos write all errorlog messages to @a logfile. */
+void
+svn_repos_set_errorlog (svn_repos_t *repos,
+ svn_stream_t *logfile);
+
+/** Set @a *logfile to the current errorlog of @a repos, or NULL if
+ none is defined. */
+void
+svn_repos_get_errorlog (svn_stream_t **logfile,
+ svn_repos_t *repos);
+
+/** Have @a repos write all accesslog messages to @a logfile. */
+void
+svn_repos_set_accesslog (svn_repos_t *repos,
+ svn_stream_t *logfile);
+
+/** Set @a *logfile to the current accesslog of @a repos, or NULL if
+ none is defined. */
+void
+svn_repos_get_accesslog (svn_stream_t **logfile,
+ svn_repos_t *repos);
+
+/** Identify the user of @a repos as @a processname. */
+void
+svn_repos_set_processname (svn_repos_t *repos,
+ const char *processname);
+
+/** Set @a *processname to the name of the process using @a repos, or
+ NULL if none is defined. */
+void
+svn_repos_get_processname (const char **processname,
+ svn_repos_t *repos);
+
+
+
+/** Write @a message into the accesslog of @a repos.
+ *
+ * If the name of the process using @a repos is not @c NULL, then log
+ * it as well. (See @c svn_repos_set_processname.)
+ *
+ * If not @c NULL, then log @a sockaddr as the incoming IP address of
+ * the request.
+ *
+ * If not @c NULL, then log @a username as the user performing the
+ * request.
+ *
+ * Use @a pool for temporary memory allocation.
+ */
+void
+svn_repos_write_accesslog (svn_repos_t *repos,
+ 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 the name of the process using @a repos is not @c NULL, then log
+ * it as well. (See @c svn_repos_set_processname.)
+ *
+ * Use @a pool for temporary memory allocation.
+ */
+void
+svn_repos_write_errorlog (svn_repos_t *repos,
+ svn_repos_loglevel_t loglevel,
+ const char *message,
+ apr_pool_t *pool);
+
+
+/** Convenience 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,
+ 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 17:00:15 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.