blockfactory  0.8
A framework for wrapping algorithms for dataflow programming
Log.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * GNU Lesser General Public License v2.1 or any later version.
7  */
8 
9 #ifndef BLOCKFACTORY_CORE_LOG_H
10 #define BLOCKFACTORY_CORE_LOG_H
11 
12 #include <memory>
13 #include <sstream>
14 #include <string>
15 
16 #ifdef NDEBUG
17 #define BF_LOG_VERBOSITY blockfactory::core::Log::Verbosity::RELEASE
18 #else
19 #define BF_LOG_VERBOSITY blockfactory::core::Log::Verbosity::DEBUG
20 #endif
21 
22 #ifndef bfError
23 #define bfError \
24  blockfactory::core::Log::getSingleton().getLogStringStream( \
25  blockfactory::core::Log::Type::ERROR, __FILE__, __LINE__, __FUNCTION__)
26 #endif
27 
28 #ifndef bfWarning
29 #define bfWarning \
30  blockfactory::core::Log::getSingleton().getLogStringStream( \
31  blockfactory::core::Log::Type::WARNING, __FILE__, __LINE__, __FUNCTION__)
32 #endif
33 
34 namespace blockfactory {
35  namespace core {
36  class Log;
37  } // namespace core
38 } // namespace blockfactory
39 
46 {
47 public:
48  enum class Type
49  {
50  ERROR,
51  WARNING
52  };
53 
54  enum class Verbosity
55  {
56  RELEASE,
57  DEBUG
58  };
59 
60 private:
61 #ifndef DOXYGEN_SHOULD_SKIP_THIS
62  class impl;
63  std::unique_ptr<impl> pImpl;
64 #endif
65 
66 public:
67  Log();
68  ~Log() = default;
69 
78 
88  std::stringstream& getLogStringStream(const Type& type,
89  const std::string& file,
90  const unsigned& line,
91  const std::string& function);
92 
97  std::string getErrors() const;
98 
103  std::string getWarnings() const;
104 
108  void clearErrors();
109 
113  void clearWarnings();
114 
118  void clear();
119 };
120 
121 #endif // BLOCKFACTORY_CORE_LOG_H
void clearErrors()
Clear the stored error messages.
Type
Definition: Log.h:48
Verbosity
Definition: Log.h:54
Definition: Block.h:17
void clearWarnings()
Clear the stored warning messages.
void clear()
Clear all the stored log messages.
std::stringstream & getLogStringStream(const Type &type, const std::string &file, const unsigned &line, const std::string &function)
Get the stringstream object for adding log messages.
Class for handling log messages.
Definition: Log.h:45
static blockfactory::core::Log & getSingleton()
Get the Log singleton.
std::string getWarnings() const
Get the stored warning messages.
std::string getErrors() const
Get the stored error messages.