/* * @project The CERN Tape Archive (CTA) * @copyright Copyright © 2021-2022 CERN * @license This program is free software, distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". You can * redistribute it and/or modify it under the terms of the GPL Version 3, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * In applying this licence, CERN does not waive the privileges and immunities * granted to it by virtue of its status as an Intergovernmental Organization or * submit itself to any jurisdiction. */ #pragma once #include "common/log/Logger.hpp" namespace cta::log { /** * A dummy logger class whose implementation of the API of the CTA logging * system does nothing. * * The primary purpose of this class is to facilitate the unit testing of * classes that require a logger object. Using an instance of this class * during unit testing means that no logs will actually be written to a log * file. */ class DummyLogger: public Logger { public: /** * Constructor * * @param hostName The name of the host to be prepended to every log * @param programName The name of the program to be prepended to every log * message. */ DummyLogger(std::string_view hostName, std::string_view programName) : Logger(hostName, programName, DEBUG) { } /** * Destructor */ ~DummyLogger() final = default; /** * Prepares the logger object for a call to fork() * * No further calls to operator() should be made after calling this * method until the call to fork() has completed */ void prepareForFork() override { /* intentionally-blank override of pure virtual method */ } protected: /** * Writes the specified msg to the underlying logging system * * This method is to be implemented by concrete sub-classes of the Logger class. * * Please note it is the responsibility of a concrete sub-class to decide * whether or not to use the specified log message header. For example, the * SysLogLogger sub-class does not use the header. Instead it relies on * rsyslog to provide a header. * * @param header The header of the message to be logged. It is the responsibility of the concrete sub-class. * @param body The body of the message to be logged */ void writeMsgToUnderlyingLoggingSystem(std::string_view header, std::string_view body) override { // intentionally-blank override of pure virtual method } }; } // namespace cta::log