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

[PATCH] Logging implementation first attempt.

From: Brian Holmes <svndev_at_gmail.com>
Date: 2005-07-28 12:57:58 CEST

I spent the last five hours hacking together this patch. It
implements a generic logging API and also implements the
svn_repos-specific functions laid out in the 3rd revision of Ben's
patch.

I've used svn_stream_t for implementing the generic logging api as
suggested by Ben and Karl. I have created three new sets of functions
for stream abstractions to handle syslog, win32 event logs, and APR
sockets.

The code works, but it's by no means perfect or bug free. The code
needs polishing and I know a several spots that aren't perfect.
However, since I'll be at "the con" for the next four days and some of
you developers will be in Portland, I want to get this out sooner
than later.

For the generic logging API there are two added files:
    /subversion/libsvn_subr/log.c
    /subversion/include/svn_log.h

Additionally the following files have been modified:
    /subversion/include/svn_io.h
    /subversion/include/svn_repos.h
    /subversion/libsvn_repos/repos.c
    /subversion/libsvn_repos/repos.h
    /subversion/libsvn_subr/stream.c:
       - (added svn_stream_t functions for APR socket)
    /subversion/svnserve/main.c:
       - (added two debug lines for proof-of-concept testing)

Here's a cut and paste of the generic logging functions:

svn_error_t* svn_log_open_empty(svn_log_t** log, apr_pool_t* pool);
svn_error_t* svn_log_open_file(svn_log_t** log, const char* path,
                               apr_pool_t* pool);
svn_error_t* svn_log_from_aprfile(svn_log_t** log, apr_file_t* file,
                                  apr_pool_t* pool);
svn_error_t* svn_log_open_stdout(svn_log_t** log, apr_pool_t* pool);
svn_error_t* svn_log_open_socket(svn_log_t** log, const char* hostname,
                                 unsigned short port, apr_pool_t* pool);
int svn_log_getlevel(svn_log_t* log);
int svn_log_setlevel(svn_log_t* log, int newlevel);
svn_error_t* svn_log_write(svn_log_t* log, apr_pool_t* pool, int loglevel,
                           const char* msg);
svn_error_t* svn_log_writes(svn_log_t* log, apr_pool_t* pool, int loglevel,
                           svn_string_t* msg);
svn_error_t* svn_log_writev(svn_log_t* log, apr_pool_t* pool, int loglevel,
                           const char* fmt, va_list ap);
svn_error_t* svn_log_writef(svn_log_t* log, apr_pool_t* pool, int loglevel,
                           const char* fmt, ...);

Here's a cut and paste of the svn_repos functions:
void svn_repos_set_processname (svn_repos_t *repos,
                           const char *processname);
void svn_repos_get_processname (const char **processname,
                           svn_repos_t *repos);
void svn_repos_set_accesslog (svn_repos_t *repos,
                         svn_log_t *logfile);
void svn_repos_get_accesslog (svn_log_t **logfile,
                         svn_repos_t *repos);
svn_error_t* svn_repos_write_accesslogf (svn_repos_t *repos,
                           apr_pool_t *pool,
                           int level,
                           const char *username,
                           const char *fmt,
                           ...);

I've added two variables to svn_repos_t:
    char *process; /* Names the owning process. Used for logging. */
    svn_log_t* log; /* The logger */

There is of course MUCH more to go but I think this is a good start.
So, read the code and let the comments fly!

- Brian Holmes
IRC: holmesbj

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Received on Thu Jul 28 12:59:11 2005

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