output_logger.h
1 /*
2 * <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2021 <copyright holder> <email>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #ifndef NAF_TOOLS_OUTPUTLOGGER
20 #define NAF_TOOLS_OUTPUTLOGGER
21 
22 
23 #include <iostream>
24 #include <fstream>
25 #include <string>
26 #include <memory>
27 #include <ostream>
28 #include <chrono>
29 #include <iomanip>
30 #include <mutex>
31 
32 
33 namespace NAF
34 {
35  namespace Tools
36  {
37  enum class LogType;
38  class OutputLogger;
39  }
40 }
41 
42 
43 enum class NAF::Tools::LogType
44 {
45  kInfo
46  ,kWarning
47  ,kError
48  ,kDebug
49 };
50 
52 {
53  public:
54  OutputLogger();
55  ~OutputLogger(){}
56 
57  static bool get_log_to_file() { return log_to_file_; }
58  static bool get_print_debug() { return print_debug_; }
59  static std::string get_output_file_address() { return output_file_address_; }
60 
61  static void set_log_to_file(bool log_to_file) { log_to_file_ = log_to_file; }
62  static void set_print_debug(bool print_debug) { print_debug_ = print_debug; }
63  static void set_output_file_address(std::string output_file_address) { output_file_address_ = output_file_address; }
64 
65  static void Log_(Tools::LogType log_type, std::string& message);
66  static void Log_(std::string message);
67  static void Warning_(std::string message);
68  static void Error_(std::string message);
69  static void Debug_(std::string message);
70  static std::string CurrentDateTime_();
71 
72  private:
73  static std::mutex mutex_;
74  static bool log_to_file_;
75  static bool print_debug_;
76  static std::string output_file_address_;
77 };
78 
79 #endif // NAF_TOOLS_OUTPUTLOGGER
Definition: output_logger.h:52