From: Abhishek Lekshmanan Date: Wed, 27 Aug 2014 10:41:53 +0000 (+0530) Subject: rgw_formats: dump_format_ns implementation X-Git-Tag: v0.86~142^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eaa2bb0aab57a430d5bdab7a5b5f540e36e87783;p=ceph.git rgw_formats: dump_format_ns implementation Since the base formatter was extended with a dump_format_ns class, implementing this here. For now, this is exactly same as dump_format, as the concept of ns in json is not used. Signed-off-by: Abhishek Lekshmanan --- diff --git a/src/rgw/rgw_formats.cc b/src/rgw/rgw_formats.cc index b69415195a5f..6008f7f4ed93 100644 --- a/src/rgw/rgw_formats.cc +++ b/src/rgw/rgw_formats.cc @@ -150,6 +150,36 @@ void RGWFormatter_Plain::dump_format(const char *name, const char *fmt, ...) write_data(format, buf); } +void RGWFormatter_Plain::dump_format_ns(const char *name, const char *fmt, const char *ns, ...) +{ + // ignore the namespace for now + char buf[LARGE_SIZE]; + va_list ap; + const char *format; + + struct plain_stack_entry& entry = stack.back(); + + if (!min_stack_level) + min_stack_level = stack.size(); + + bool should_print = (stack.size() == min_stack_level && !entry.size); + + entry.size++; + + if (!should_print) + return; + + va_start(ap, fmt); + vsnprintf(buf, LARGE_SIZE, fmt, ap); + va_end(ap); + if (len) + format = "\n%s"; + else + format = "%s"; + + write_data(format, buf); +} + int RGWFormatter_Plain::get_len() const { // don't include null termination in length diff --git a/src/rgw/rgw_formats.h b/src/rgw/rgw_formats.h index 017be090cd20..aff53dc53453 100644 --- a/src/rgw/rgw_formats.h +++ b/src/rgw/rgw_formats.h @@ -42,6 +42,7 @@ public: virtual void dump_format_unquoted(const char *name, const char *fmt, ...) { assert(0 == "not implemented"); } + virtual void dump_format_ns(const char *name, const char *ns, const char *fmt, ...); virtual int get_len() const; virtual void write_raw_data(const char *data);