From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wei.liu2@citrix.com>, Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH 5/6] xenconsoled: options to control log rotation
Date: Mon, 6 Jun 2016 16:59:40 +0100 [thread overview]
Message-ID: <1465228781-22754-6-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1465228781-22754-1-git-send-email-wei.liu2@citrix.com>
Provide two options: one to control the maximum number of copies kept
and the other to control the maximum length of each log file.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
tools/console/daemon/logfile.c | 11 +++++++----
tools/console/daemon/main.c | 13 ++++++++++++-
2 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/tools/console/daemon/logfile.c b/tools/console/daemon/logfile.c
index ad73f8e..3b95f84 100644
--- a/tools/console/daemon/logfile.c
+++ b/tools/console/daemon/logfile.c
@@ -25,6 +25,9 @@
#include "utils.h"
#include "logfile.h"
+extern unsigned int log_backups;
+extern unsigned int log_max_len;
+
static void logfile_entry_free(struct logfile_entry *entry)
{
if (!entry) return;
@@ -91,7 +94,7 @@ struct logfile *logfile_new(const char *path, mode_t mode)
}
logfile->mode = mode;
- logfile->maxlen = LOGFILE_MAX_SIZE;
+ logfile->maxlen = log_max_len;
logfile->entry = logfile_entry_new(logfile->basepath, mode);
@@ -112,13 +115,13 @@ static int logfile_rollover(struct logfile *file)
unsigned i;
if (asprintf(&next, "%s.%u", file->basepath,
- LOGFILE_MAX_BACKUP_NUM) < 0) {
+ log_backups) < 0) {
dolog(LOG_ERR, "Failed to asprintf %s.%u",
- file->basepath, LOGFILE_MAX_BACKUP_NUM);
+ file->basepath, log_backups);
goto err;
}
- for (i = LOGFILE_MAX_BACKUP_NUM; i > 0; i--) {
+ for (i = log_backups; i > 0; i--) {
if (i == 1) {
this = strdup(file->basepath);
if (!this) {
diff --git a/tools/console/daemon/main.c b/tools/console/daemon/main.c
index 23860d3..dd338ae 100644
--- a/tools/console/daemon/main.c
+++ b/tools/console/daemon/main.c
@@ -31,6 +31,7 @@
#include "utils.h"
#include "io.h"
+#include "logfile.h"
int log_reload = 0;
int log_guest = 0;
@@ -39,6 +40,8 @@ int log_time_hv = 0;
int log_time_guest = 0;
char *log_dir = NULL;
int discard_overflowed_data = 1;
+unsigned int log_backups = LOGFILE_MAX_BACKUP_NUM;
+unsigned int log_max_len = LOGFILE_MAX_SIZE;
static void handle_hup(int sig)
{
@@ -47,7 +50,7 @@ static void handle_hup(int sig)
static void usage(char *name)
{
- printf("Usage: %s [-h] [-V] [-v] [-i] [--log=none|guest|hv|all] [--log-dir=DIR] [--pid-file=PATH] [-t, --timestamp=none|guest|hv|all] [-o, --overflow-data=discard|keep]\n", name);
+ printf("Usage: %s [-h] [-V] [-v] [-i] [--log=none|guest|hv|all] [--log-dir=DIR] [--pid-file=PATH] [--log-backups=NUM] [--log-max-len=NUM] [-t, --timestamp=none|guest|hv|all] [-o, --overflow-data=discard|keep]\n", name);
}
static void version(char *name)
@@ -100,6 +103,8 @@ int main(int argc, char **argv)
{ "interactive", 0, 0, 'i' },
{ "log", 1, 0, 'l' },
{ "log-dir", 1, 0, 'r' },
+ { "log-backups", 1, 0, 'n' },
+ { "log-max-len", 1, 0, 'm' },
{ "pid-file", 1, 0, 'p' },
{ "timestamp", 1, 0, 't' },
{ "overflow-data", 1, 0, 'o'},
@@ -144,6 +149,12 @@ int main(int argc, char **argv)
case 'r':
log_dir = strdup(optarg);
break;
+ case 'n':
+ log_backups = strtoul(optarg, 0, 0);
+ break;
+ case 'm':
+ log_max_len = strtoul(optarg, 0, 0);
+ break;
case 'p':
pidfile = strdup(optarg);
break;
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-06 15:59 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 15:59 [PATCH 0/6] xenconsoled: rotating log file abstration Wei Liu
2016-06-06 15:59 ` [PATCH 1/6] xenconsoled: introduce log file abstraction Wei Liu
2016-07-08 16:50 ` Ian Jackson
2016-06-06 15:59 ` [PATCH 2/6] xenconsoled: switch hypervisor log to use logfile abstraction Wei Liu
2016-07-08 16:58 ` Ian Jackson
2016-06-06 15:59 ` [PATCH 3/6] xenconsoled: switch guest " Wei Liu
2016-07-08 17:01 ` Ian Jackson
2016-06-06 15:59 ` [PATCH 4/6] xenconsoled: delete two now unused functions Wei Liu
2016-07-08 17:01 ` Ian Jackson
2016-06-06 15:59 ` Wei Liu [this message]
2016-07-08 17:02 ` [PATCH 5/6] xenconsoled: options to control log rotation Ian Jackson
2016-06-06 15:59 ` [PATCH 6/6] xenconsoled: handle --log-backups 0 in logfile_rollover Wei Liu
2016-07-08 17:03 ` Ian Jackson
2016-06-06 20:40 ` [PATCH 0/6] xenconsoled: rotating log file abstration Doug Goldstein
2016-06-07 8:07 ` Wei Liu
2016-06-07 9:44 ` David Vrabel
2016-06-07 9:55 ` Wei Liu
2016-06-07 10:17 ` David Vrabel
2016-06-07 10:21 ` Wei Liu
2016-06-07 10:29 ` David Vrabel
2016-06-07 10:34 ` Wei Liu
2016-06-07 10:35 ` David Vrabel
2016-06-07 10:43 ` Wei Liu
2016-07-02 10:24 ` Wei Liu
2016-07-04 17:07 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465228781-22754-6-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).