summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-12-15 06:11:41 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-12-15 06:11:41 +0000
commit9ccd89dc288ca61c89012da10393343c374c6a44 (patch)
tree41ea3c9292eafc66b19dfcee8f473de8be4cb3ff /usr.bin/cvs
parent1d0ee361f1d8049725cbc01cc4837ab672e248e5 (diff)
Permit the client to generate trace output when the -t option is given
by using the LP_TRACE level to cvs_log(). Traces are filtered by default.
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/cvs.c3
-rw-r--r--usr.bin/cvs/log.c20
-rw-r--r--usr.bin/cvs/log.h5
3 files changed, 20 insertions, 8 deletions
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index aecdc03ca0e..57cc7df5929 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.23 2004/12/14 19:56:35 xsa Exp $ */
+/* $OpenBSD: cvs.c,v 1.24 2004/12/15 06:11:40 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -473,6 +473,7 @@ cvs_getopt(int argc, char **argv)
cvs_readonly = 1;
break;
case 't':
+ (void)cvs_log_filter(LP_FILTER_UNSET, LP_TRACE);
cvs_trace = 1;
break;
case 'v':
diff --git a/usr.bin/cvs/log.c b/usr.bin/cvs/log.c
index 0932ca5162d..d091c2bf975 100644
--- a/usr.bin/cvs/log.c
+++ b/usr.bin/cvs/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.7 2004/12/07 17:10:56 tedu Exp $ */
+/* $OpenBSD: log.c,v 1.8 2004/12/15 06:11:40 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -95,6 +95,9 @@ cvs_log_init(u_int dest, u_int flags)
cvs_log_filters[LP_DEBUG] = 1;
cvs_log_filters[LP_INFO] = 1;
+ /* traces are enabled with the -t command-line option */
+ cvs_log_filters[LP_TRACE] = 1;
+
if (dest & LD_SYSLOG) {
slopt = 0;
@@ -212,7 +215,6 @@ cvs_vlog(u_int level, const char *fmt, va_list vap)
if (level > LP_MAX)
return (-1);
-
/* apply any filters */
if (cvs_log_filters[level] != 0)
return (0);
@@ -224,7 +226,11 @@ cvs_vlog(u_int level, const char *fmt, va_list vap)
#ifdef CVS
/* The cvs program appends the command name to the program name */
- if (cvs_command != NULL) {
+ if (level == LP_TRACE) {
+ strlcpy(prefix, " -> ", sizeof(prefix));
+ if (cvs_cmdop == CVS_OP_SERVER)
+ prefix[0] = 'S';
+ } else if (cvs_command != NULL) {
if (level == LP_ABORT)
snprintf(prefix, sizeof(prefix), "%s [%s aborted]",
__progname, cvs_command);
@@ -235,7 +241,7 @@ cvs_vlog(u_int level, const char *fmt, va_list vap)
#endif
strlcpy(prefix, __progname, sizeof(prefix));
- if (cvs_log_flags & LF_PID) {
+ if ((cvs_log_flags & LF_PID) && (level != LP_TRACE)) {
snprintf(buf, sizeof(buf), "[%d]", (int)getpid());
strlcat(prefix, buf, sizeof(prefix));
}
@@ -262,7 +268,11 @@ cvs_vlog(u_int level, const char *fmt, va_list vap)
}
#endif
- fprintf(out, "%s: %s\n", prefix, buf);
+ fputs(prefix, out);
+ if (level != LP_TRACE)
+ fputs(": ", out);
+ fputs(buf, out);
+ fputc('\n', out);
}
if (cvs_log_dest & LD_SYSLOG)
diff --git a/usr.bin/cvs/log.h b/usr.bin/cvs/log.h
index 79dbebf8b58..344b4f01f0c 100644
--- a/usr.bin/cvs/log.h
+++ b/usr.bin/cvs/log.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.h,v 1.4 2004/12/07 17:10:56 tedu Exp $ */
+/* $OpenBSD: log.h,v 1.5 2004/12/15 06:11:40 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -53,8 +53,9 @@
#define LP_ALERT 5
#define LP_ERRNO 6
#define LP_ABORT 7
+#define LP_TRACE 8
-#define LP_MAX 7
+#define LP_MAX 8
#define LP_ALL 255
/* filtering methods */