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

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Tue Jan 29 10:30:16 CET 2013


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 a 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..b4fb2fc 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -60,6 +60,7 @@ static struct sd_option sheep_options[] = {
 	{'w', "write-cache", true, "specify the cache type"},
 	{'y', "myaddr", true, "specify the address advertised to other sheep"},
 	{'z', "zone", true, "specify the zone id"},
+	{'F', "log-format", true, "specify log format"},
 	{ 0, NULL, false, NULL },
 };
 
@@ -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.2.5




More information about the sheepdog mailing list