summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-08-05 13:32:09 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2004-08-05 13:32:09 +0000
commit0716077c02489661fbe6cdb041ff8d81cd800b41 (patch)
tree8bfe5815156952ff8433f8ede9f29c207fe9e7e1 /usr.bin
parent76f425e0946950c6947472c9886d710557009e98 (diff)
Adapt the logging so any messages generated by the server will be
prepended with a 'M' or 'E' command, depending on the log level, and follow the GNU behaviour of printing the command name after the program name in messages
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cvs/cvs.h6
-rw-r--r--usr.bin/cvs/log.c25
2 files changed, 28 insertions, 3 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index 3cc5c94c922..4c131219d1c 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.21 2004/08/05 13:24:37 jfb Exp $ */
+/* $OpenBSD: cvs.h,v 1.22 2004/08/05 13:32:08 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -223,7 +223,11 @@ typedef struct cvs_histfile {
#ifdef CVS
+extern char *cvs_command;
extern char *cvs_editor;
+
+extern int cvs_cmdop;
+
#endif
diff --git a/usr.bin/cvs/log.c b/usr.bin/cvs/log.c
index 6b90c675549..ca5a305d117 100644
--- a/usr.bin/cvs/log.c
+++ b/usr.bin/cvs/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.2 2004/07/27 16:19:41 jfb Exp $ */
+/* $OpenBSD: log.c,v 1.3 2004/08/05 13:32:08 jfb Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -35,9 +35,11 @@
#include <syslog.h>
#include "log.h"
+#include "cvs.h"
extern char *__progname;
+
#ifdef unused
static char *cvs_log_levels[] = {
"debug",
@@ -222,7 +224,16 @@ cvs_vlog(u_int level, const char *fmt, va_list vap)
if (level == LP_ERRNO)
ecp = errno;
- strlcpy(prefix, __progname, sizeof(prefix));
+#ifdef CVS
+ /* The cvs program appends the command name to the program name */
+ if (cvs_command != NULL) {
+ snprintf(prefix, sizeof(prefix), "%s %s", __progname,
+ cvs_command);
+ }
+ else /* just use the standard strlcpy */
+#endif
+ strlcpy(prefix, __progname, sizeof(prefix));
+
if (cvs_log_flags & LF_PID) {
snprintf(buf, sizeof(buf), "[%d]", (int)getpid());
strlcat(prefix, buf, sizeof(prefix));
@@ -240,6 +251,16 @@ cvs_vlog(u_int level, const char *fmt, va_list vap)
else
out = stderr;
+#ifdef CVS
+ if (cvs_cmdop == CVS_OP_SERVER) {
+ if (out == stdout)
+ putc('M', out);
+ else
+ putc('E', out);
+ putc(' ', out);
+ }
+#endif
+
fprintf(out, "%s: %s\n", prefix, buf);
}