From 63202ff1e64b3cdc320104d6b358c353f0a9444c Mon Sep 17 00:00:00 2001 From: "Andrey A. Chernov" Date: Sun, 4 May 1997 02:39:04 +0000 Subject: [PATCH] Log each ppp line to separate /var/log/ppp.tunX.log instead mixing of all lines into single /var/log/ppp.log --- usr.sbin/ppp/defs.h | 4 ++-- usr.sbin/ppp/log.c | 23 +++++++++++++++-------- usr.sbin/ppp/log.h | 7 ++++--- usr.sbin/ppp/main.c | 8 ++------ usr.sbin/ppp/os.c | 7 ++++++- usr.sbin/ppp/ppp.8 | 6 +++--- usr.sbin/ppp/ppp.8.m4 | 6 +++--- 7 files changed, 35 insertions(+), 26 deletions(-) diff --git a/usr.sbin/ppp/defs.h b/usr.sbin/ppp/defs.h index edcc665c262..a6b715288a0 100644 --- a/usr.sbin/ppp/defs.h +++ b/usr.sbin/ppp/defs.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: defs.h,v 1.11 1997/04/14 23:48:13 brian Exp $ + * $Id: defs.h,v 1.12 1997/04/21 01:01:41 brian Exp $ * * TODO: */ @@ -36,7 +36,7 @@ /* * Check follwiing definitions for your machine envirinment */ -#define LOGFILE "/var/log/ppp.log" /* Name of log file */ +#define LOGFILE "/var/log/ppp.tun%d.log" /* Name of log file */ #ifdef __FreeBSD__ #define MODEM_DEV "/dev/cuaa1" /* name of tty device */ #else diff --git a/usr.sbin/ppp/log.c b/usr.sbin/ppp/log.c index 2f57814df31..2a45c2087bb 100644 --- a/usr.sbin/ppp/log.c +++ b/usr.sbin/ppp/log.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: log.c,v 1.7 1997/02/22 16:10:26 peter Exp $ + * $Id: log.c,v 1.8 1997/03/13 14:53:53 brian Exp $ * */ #include "defs.h" @@ -42,7 +42,7 @@ static FILE *logfile; #endif static char logbuff[2000]; -static char *logptr; +char *logptr; static struct mbuf *logtop; static struct mbuf *lognext; static int logcnt; @@ -62,12 +62,16 @@ ListLog() } int -LogOpen() +LogOpen(tunno) +int tunno; { #ifdef USELOGFILE - logfile = fopen(LOGFILE, "a"); + char buf[80]; + + sprintf(buf, LOGFILE, tunno); + logfile = fopen(buf, "a"); if (logfile == NULL) { - fprintf(stderr, "can't open %s.\r\n", LOGFILE); + fprintf(stderr, "can't open %s.\r\n", buf); return(1); } #endif @@ -122,6 +126,7 @@ LogClose() #ifdef USELOGFILE fclose(logfile); #endif + logptr = NULL; } #ifdef NO_VSPRINTF @@ -285,12 +290,14 @@ void LogReOpen( sig ) int sig; { +#ifdef USELOGFILE FILE *nlogfile; + char buf[80]; -#ifdef USELOGFILE - nlogfile = fopen(LOGFILE, "a"); + sprintf(buf, LOGFILE, tunno); + nlogfile = fopen(buf, "a"); if (nlogfile == NULL) { - LogPrintf(~0,"can't re-open %s.\r\n", LOGFILE); + LogPrintf(~0,"can't re-open %s.\r\n", buf); } else { LogPrintf(~0,"log file closed due to signal %d.\r\n",sig); diff --git a/usr.sbin/ppp/log.h b/usr.sbin/ppp/log.h index d56b77b8a03..31ae57dccd5 100644 --- a/usr.sbin/ppp/log.h +++ b/usr.sbin/ppp/log.h @@ -15,7 +15,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: log.h,v 1.8 1997/02/22 16:10:27 peter Exp $ + * $Id: log.h,v 1.9 1997/03/13 14:53:54 brian Exp $ * * TODO: */ @@ -58,10 +58,11 @@ # define LM_CARRIER "Carrier" #define MAXLOGLEVEL 10 -extern int loglevel; +extern int loglevel, tunno; +extern char *logptr; extern void LogTimeStamp __P((void)); -extern int LogOpen __P((void)); +extern int LogOpen __P((int)); extern void LogReOpen __P((int)); extern void DupLog __P((void)); extern void LogClose __P((void)); diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c index f1e1d00b0a8..8c50561f087 100644 --- a/usr.sbin/ppp/main.c +++ b/usr.sbin/ppp/main.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: main.c,v 1.44 1997/04/14 23:48:15 brian Exp $ + * $Id: main.c,v 1.45 1997/04/21 01:01:48 brian Exp $ * * TODO: * o Add commands for traffic summary, version display, etc. @@ -78,6 +78,7 @@ static int server; static pid_t BGPid = 0; struct sockaddr_in ifsin; char pid_filename[128]; +int tunno; static void TtyInit() @@ -296,8 +297,6 @@ main(argc, argv) int argc; char **argv; { - int tunno; - argc--; argv++; mode = MODE_INTER; /* default operation is interactive mode */ @@ -312,9 +311,6 @@ char **argv; fprintf(stderr, "Warning: No default entry is given in config file.\n"); } - if (LogOpen()) - exit(EX_START); - switch ( LocalAuthInit() ) { case NOT_FOUND: fprintf(stderr,LAUTH_M1); diff --git a/usr.sbin/ppp/os.c b/usr.sbin/ppp/os.c index d16a8e86965..c0ffdb8d98e 100644 --- a/usr.sbin/ppp/os.c +++ b/usr.sbin/ppp/os.c @@ -17,7 +17,7 @@ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. * - * $Id: os.c,v 1.14 1997/02/25 14:05:06 brian Exp $ + * $Id: os.c,v 1.15 1997/04/15 00:03:36 brian Exp $ * */ #include "fsm.h" @@ -294,6 +294,11 @@ int *ptun; } *ptun = unit; + if (logptr != NULL) + LogClose(); + if (LogOpen(unit)) + return(-1); + /* * At first, name the interface. */ diff --git a/usr.sbin/ppp/ppp.8 b/usr.sbin/ppp/ppp.8 index f4431ee1618..f98f03e74cf 100644 --- a/usr.sbin/ppp/ppp.8 +++ b/usr.sbin/ppp/ppp.8 @@ -1,5 +1,5 @@ .\" manual page [] for ppp 0.94 beta2 + alpha -.\" $Id: ppp.8,v 1.29 1997/04/14 23:48:17 brian Exp $ +.\" $Id: ppp.8,v 1.30 1997/04/21 01:01:56 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -1032,7 +1032,7 @@ ISPs. .Nm is able to generate the following log info into -.Pa /var/log/ppp.log : +.Pa /var/log/ppp.tun0.log : .Bl -column SMMMMMM -offset indent -compat .It Li Phase Phase transition log output @@ -1110,7 +1110,7 @@ A file to check when .Nm establishes a network level connection. -.Pa /var/log/ppp.log +.Pa /var/log/ppp.tun0.log Logging and debugging information file. .Pa /var/spool/lock/Lck..* diff --git a/usr.sbin/ppp/ppp.8.m4 b/usr.sbin/ppp/ppp.8.m4 index f4431ee1618..f98f03e74cf 100644 --- a/usr.sbin/ppp/ppp.8.m4 +++ b/usr.sbin/ppp/ppp.8.m4 @@ -1,5 +1,5 @@ .\" manual page [] for ppp 0.94 beta2 + alpha -.\" $Id: ppp.8,v 1.29 1997/04/14 23:48:17 brian Exp $ +.\" $Id: ppp.8,v 1.30 1997/04/21 01:01:56 brian Exp $ .Dd 20 September 1995 .Os FreeBSD .Dt PPP 8 @@ -1032,7 +1032,7 @@ ISPs. .Nm is able to generate the following log info into -.Pa /var/log/ppp.log : +.Pa /var/log/ppp.tun0.log : .Bl -column SMMMMMM -offset indent -compat .It Li Phase Phase transition log output @@ -1110,7 +1110,7 @@ A file to check when .Nm establishes a network level connection. -.Pa /var/log/ppp.log +.Pa /var/log/ppp.tun0.log Logging and debugging information file. .Pa /var/spool/lock/Lck..* -- 2.45.2