message_handler.h
Go to the documentation of this file.
1 /*
2  * Software License Agreement (BSD-3 License)
3  *
4  * Copyright (c) 2018 Daniel Koch.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * * Redistributions of source code must retain the above copyright notice, this
11  * list of conditions and the following disclaimer.
12  *
13  * * Redistributions in binary form must reproduce the above copyright notice,
14  * this list of conditions and the following disclaimer in the documentation
15  * and/or other materials provided with the distribution.
16  *
17  * * Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from
19  * this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
38 #ifndef ASYNC_COMM_MESSAGE_HANDLER_H
39 #define ASYNC_COMM_MESSAGE_HANDLER_H
40 
41 #include <iostream>
42 #include <string>
43 
44 namespace async_comm
45 {
46 
56 {
57 public:
58  virtual void debug(const std::string& message) = 0;
59  virtual void info(const std::string& message) = 0;
60  virtual void warn(const std::string& message) = 0;
61  virtual void error(const std::string& message) = 0;
62  virtual void fatal(const std::string& message) = 0;
63 };
64 
70 {
71 public:
72  inline void debug(const std::string &message) override { std::cout << "[async_comm][DEBUG]: " << message << std::endl; }
73  inline void info(const std::string &message) override { std::cout << "[async_comm][INFO]: " << message << std::endl; }
74  inline void warn(const std::string &message) override { std::cerr << "[async_comm][WARN]: " << message << std::endl; }
75  inline void error(const std::string &message) override { std::cerr << "[async_comm][ERROR]: " << message << std::endl; }
76  inline void fatal(const std::string &message) override { std::cerr << "[async_comm][FATAL]: " << message << std::endl; }
77 };
78 
79 } // namespace async_comm
80 
81 #endif // ASYNC_COMM_MESSAGE_HANDLER_H
virtual void warn(const std::string &message)=0
void error(const std::string &message) override
virtual void error(const std::string &message)=0
void info(const std::string &message) override
virtual void fatal(const std::string &message)=0
void fatal(const std::string &message) override
Abstract base class for message handler.
void warn(const std::string &message) override
Default message handler that outputs to stdout and stderr.
void debug(const std::string &message) override
virtual void info(const std::string &message)=0
virtual void debug(const std::string &message)=0


async_comm
Author(s):
autogenerated on Fri May 14 2021 02:35:38