[sheepdog] [PATCH v3 3/3] sheep: add new option -F for selecting log format

Hitoshi Mitake mitake.hitoshi at gmail.com
Tue Jan 29 13:04:55 CET 2013


From: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>

This patch adds new option '-F' (or '--log-format') to sheep. With
this option, users can specify a log format. e.g.
sheep -F json /store/sheep     # format log with json
sheep -F default /store/sheep  # format with default style

Without -F option, sheep selects the default style for formatting.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 sheep/sheep.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index 50810c7..0068c5a 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -46,6 +46,7 @@ static struct sd_option sheep_options[] = {
 	{'d', "debug", false, "include debug messages in the log"},
 	{'D', "directio", false, "use direct IO for backend store"},
 	{'f', "foreground", false, "make the program run in the foreground"},
+	{'F', "log-format", true, "specify log format"},
 	{'g', "gateway", false, "make the progam run as a gateway mode"},
 	{'h', "help", false, "display this help and exit"},
 	{'i', "ioaddr", true, "use separate network card to handle IO requests"},
@@ -430,6 +431,7 @@ int main(int argc, char **argv)
 	int64_t zone = -1, free_space = 0;
 	struct cluster_driver *cdrv;
 	struct option *long_options;
+	const char *log_format = "default";
 
 	signal(SIGPIPE, SIG_IGN);
 
@@ -565,6 +567,9 @@ int main(int argc, char **argv)
 				PACKAGE_VERSION);
 			exit(0);
 			break;
+		case 'F':
+			log_format = optarg;
+			break;
 		default:
 			usage(1);
 			break;
@@ -596,7 +601,7 @@ int main(int argc, char **argv)
 		exit(1);
 
 	ret = log_init(program_name, LOG_SPACE_SIZE, to_stdout, log_level, path,
-		"default");
+		log_format);
 	if (ret)
 		exit(1);
 
-- 
1.7.5.1




More information about the sheepdog mailing list