]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common: make LogChannel mockable 46079/head
authorRonen Friedman <rfriedma@redhat.com>
Thu, 28 Apr 2022 07:35:58 +0000 (07:35 +0000)
committerRonen Friedman <rfriedma@redhat.com>
Sat, 30 Apr 2022 14:57:28 +0000 (14:57 +0000)
commitab64ebb909f55fce7d5eb433af0dfa842c14561b
treee37e1da9607d161aadae6b17f16862165895e6db
parent5ba7d8520d02dbf876b7c07fd978e9987e1795c8
common: make LogChannel mockable

Adding LoggerSinkSet, an abstract API that enables unit-testing
of OSD components that emit cluster-log messages, and trapping the
logs.

First usage example is in the Scrubber backend unit-tests.
The log "implementation" there (note the error counter that
can be used to determine tests success):

 class MockLog : public LoggerSinkSet {
 public:
  void warn(std::stringstream& s) override
  {
    std::cout << "\n<<warn>> " << s.str() << std::endl;
  }
  void error(std::stringstream& s) override
  {
    err_count++;
    std::cout << "\n<<error>> " << s.str() << std::endl;
  }
  ...

Signed-off-by: Ronen Friedman <rfriedma@redhat.com>
src/common/LogClient.h
src/common/ostream_temp.h
src/crimson/common/logclient.h