FreeBSD Bugzilla – Attachment 15905 Details for
Bug 29363
[patch] newsyslog(8) can support time as extension
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 3.86 KB, created by
dirk.meyer
on 2001-08-01 11:20:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
dirk.meyer
Created:
2001-08-01 11:20:01 UTC
Size:
3.86 KB
patch
obsolete
>Index: newsyslog.8 >=================================================================== >RCS file: /home/ncvs/src/usr.sbin/newsyslog/newsyslog.8,v >retrieving revision 1.32 >diff -u -r1.32 newsyslog.8 >--- newsyslog.8 2001/07/30 15:17:17 1.32 >+++ newsyslog.8 2001/08/01 10:09:09 >@@ -28,6 +28,7 @@ > .Op Fl Fnrv > .Op Fl f Ar config_file > .Op Fl a Ar directory >+.Op Fl T Ar timeformat > .Op Ar > .Sh DESCRIPTION > .Nm Newsyslog >@@ -354,6 +355,14 @@ > to trim the logs, even if the trim conditions have not been met. This > option is useful for diagnosing system problems by providing you with > fresh logs that contain only the problems. >+.It Fl T >+Time based extension >+.Nm >+to rename all logs that get trimmed into with an extension based on the >+argument given by this option. This option can be any strfime(3) string. >+ This function is intended for permantely storing of logfiles. If the >+patten results to an already existing file, operations breaks without >+cleanup, leaving stale logs in place, that might be ovewritten. > .El > .Pp > If additional command line arguments are given, >Index: newsyslog.c >=================================================================== >RCS file: /home/ncvs/src/usr.sbin/newsyslog/newsyslog.c,v >retrieving revision 1.37 >diff -u -r1.37 newsyslog.c >--- newsyslog.c 2001/07/31 16:25:55 1.37 >+++ newsyslog.c 2001/08/01 10:09:12 >@@ -90,7 +90,9 @@ > int needroot = 1; /* Root privs are necessary */ > int noaction = 0; /* Don't do anything, just show it */ > int force = 0; /* Force the trim no matter what */ >-char *archdirname; /* Directory path to old logfiles archive */ >+int timename = 0; /* Use time of rotation as suffix */ >+const char *archdirname; /* Directory path to old logfiles archive */ >+const char *timearg; /* Pattern to expand into extension */ > const char *conf = _PATH_CONF; /* Configuration file to use */ > time_t timenow; > >@@ -227,7 +229,7 @@ > if ((p = strchr(hostname, '.'))) { > *p = '\0'; > } >- while ((c = getopt(argc, argv, "nrvFf:a:t:")) != -1) >+ while ((c = getopt(argc, argv, "nrvFf:a:t:T:")) != -1) > switch (c) { > case 'n': > noaction++; >@@ -248,6 +250,10 @@ > case 'F': > force++; > break; >+ case 'T': >+ timename++; >+ timearg = optarg; >+ break; > default: > usage(); > } >@@ -516,6 +522,7 @@ > int notified, need_notification, fd, _numdays; > struct stat st; > pid_t pid; >+ time_t now; > > #ifdef _IBMR2 > /* >@@ -633,6 +640,16 @@ > if (noaction) > printf("mv %s to %s\n", log, file1); > else { >+ /* change file1 to hold the new name */ >+ if (timename) { >+ now = time( NULL ); >+ (void) strftime(file2, sizeof(file2), timearg, localtime( &now ) ); >+ if (archtodir) >+ (void) snprintf(file1, sizeof(file1), "%s/%s.%s", dirpart, namepart, file2); >+ else >+ (void) snprintf(file1, sizeof(file1), "%s.%s", log, file2); >+ } >+ > if (archtodir) > movefile(log, file1, perm, owner_uid, > group_gid); >@@ -683,26 +700,18 @@ > "log %s not compressed because daemon not notified", > log); > else if (noaction) >- printf("Compress %s.0\n", log); >+ printf("Compress %s\n", file1); > else { > if (notified) { > if (verbose) > printf("small pause to allow daemon to close log\n"); > sleep(10); >- } >- if (archtodir) { >- (void) snprintf(file1, sizeof(file1), "%s/%s", >- dirpart, namepart); >- if (flags & CE_COMPACT) >- compress_log(file1); >- else if (flags & CE_BZCOMPACT) >- bzcompress_log(file1); >- } else { >- if (flags & CE_COMPACT) >- compress_log(log); >- else if (flags & CE_BZCOMPACT) >- bzcompress_log(log); > } >+ compress_log(file1); >+ if (flags & CE_COMPACT) >+ compress_log(file1); >+ else if (flags & CE_BZCOMPACT) >+ bzcompress_log(file1); > } > } > } >@@ -729,7 +738,7 @@ > pid_t pid; > char tmp[MAXPATHLEN]; > >- (void) snprintf(tmp, sizeof(tmp), "%s.0", log); >+ (void) snprintf(tmp, sizeof(tmp), "%s", log); > pid = fork(); > if (pid < 0) > err(1, "gzip fork");
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 29363
: 15905 |
15906