]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
dout.h: add a DoutPrefixProvider and macro to allow passing of prefixes
authorSamuel Just <sjust@redhat.com>
Mon, 30 Mar 2015 23:46:10 +0000 (16:46 -0700)
committerSamuel Just <sjust@redhat.com>
Thu, 25 Feb 2016 18:56:41 +0000 (10:56 -0800)
This way, we can get proper logging within static functions.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/common/dout.h

index 22befd67e0cecd90182d73df5b233975cf26e95a..9f8fd27dd3d1ea1c1528e394f12035064894c96f 100644 (file)
@@ -39,6 +39,14 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
   return out;
 }
 
+class DoutPrefixProvider {
+public:
+  virtual string gen_prefix() const = 0;
+  virtual CephContext *get_cct() const = 0;
+  virtual unsigned get_subsys() const = 0;
+  virtual ~DoutPrefixProvider() {}
+};
+
 // generic macros
 #define dout_prefix *_dout
 
@@ -58,6 +66,8 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
 #define ldout(cct, v)  dout_impl(cct, dout_subsys, v) dout_prefix
 #define lderr(cct) dout_impl(cct, ceph_subsys_, -1) dout_prefix
 
+#define ldpp_dout(dpp, v) if (dpp) dout_impl(dpp->get_cct(), dpp->get_subsys(), v) (*_dout << dpp->gen_prefix())
+
 #define lgeneric_subdout(cct, sub, v) dout_impl(cct, ceph_subsys_##sub, v) *_dout
 #define lgeneric_dout(cct, v) dout_impl(cct, ceph_subsys_, v) *_dout
 #define lgeneric_derr(cct) dout_impl(cct, ceph_subsys_, -1) *_dout