[Sheepdog] [PATCH] support specifying output log file

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Wed Apr 7 05:46:05 CEST 2010


On Wed, 7 Apr 2010 12:41:36 +0900
FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp> wrote:

> On Tue,  6 Apr 2010 14:12:11 +0900
> MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp> wrote:
> 
> > When running more than one collies in the same machine, it is
> > confusing to send all the output to the syslog.
> > 
> > You can specify the output file with -o option.
> > 
> > $ collie -o /tmp/sdog /store
> > (log messages are sent to /tmp/sdog)
> > 
> > $ script/start-sheepdog -n=3 -o=/tmp/sdog- -d=/store
> > (log messages are sent to /tmp/sdog-0, /tmp/sdog-1, and /tmp/sdog-2)
> > 
> > Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
> > ---
> >  collie/collie.c       |   14 ++++++++++++--
> >  include/logger.h      |    3 ++-
> >  lib/logger.c          |   21 +++++++++++++++++----
> >  script/start-sheepdog |   15 +++++++++++----
> >  4 files changed, 42 insertions(+), 11 deletions(-)
> > 
> > diff --git a/collie/collie.c b/collie/collie.c
> > index 8367487..0acc2d2 100644
> > --- a/collie/collie.c
> > +++ b/collie/collie.c
> > @@ -25,12 +25,13 @@ static struct option const long_options[] = {
> >  	{"port", required_argument, 0, 'p'},
> >  	{"foreground", no_argument, 0, 'f'},
> >  	{"loglevel", required_argument, 0, 'l'},
> > +	{"outfile", required_argument, 0, 'o'},
> >  	{"debug", no_argument, 0, 'd'},
> >  	{"help", no_argument, 0, 'h'},
> >  	{0, 0, 0, 0},
> >  };
> >  
> > -static char *short_options = "p:fl:dh";
> > +static char *short_options = "p:fl:o:dh";
> >  
> >  static void usage(int status)
> >  {
> > @@ -44,6 +45,7 @@ Sheepdog Daemon, version %s\n\
> >    -p, --port              specify the listen port number\n\
> >    -f, --foreground        make the program run in the foreground\n\
> >    -l, --loglevel          specify the message level printed by default\n\
> > +  -o, --outfile           location for output (defaults to the system log)\n\
> >    -d, --debug             print debug messages\n\
> >    -h, --help              display this help and exit\n\
> >  ", SD_VERSION);
> > @@ -60,6 +62,7 @@ int main(int argc, char **argv)
> >  	char *dir = DEFAULT_OBJECT_DIR;
> >  	int is_daemon = 1;
> >  	int log_level = LOG_INFO;
> > +	char *out_file = NULL;
> >  
> >  	while ((ch = getopt_long(argc, argv, short_options, long_options,
> >  				 &longindex)) >= 0) {
> > @@ -72,6 +75,12 @@ int main(int argc, char **argv)
> >  			break;
> >  		case 'l':
> >  			log_level = atoi(optarg);
> > +			break;
> > +		case 'o':
> > +			out_file = optarg;
> > +			if (strcmp(out_file, "syslog") == 0)
> > +				out_file = NULL;
> 
> I don't think we need this. There is no point to provide two different
> ways to do the same thing.
> 
> I also think that it's better to avoid syslog by default.
> 
> anyway, here's a patch that addresses the above issues.

Oops, this patch also addresses the problem that we don't write the
time and date information to a log file.



More information about the sheepdog mailing list