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 ATOM_TOOLS_OUTPUTLOGGER
20 #define ATOM_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 Atom
34 {
35  namespace Tools
36  {
37  class OutputLogger;
38  }
39 }
40 
41 
43 {
44  public:
45  OutputLogger();
46  ~OutputLogger(){}
47 
48  static bool get_log_to_file() { return log_to_file_; }
49  static std::string get_output_file_address() { return output_file_address_; }
50 
51  static void set_log_to_file(bool log_to_file) { log_to_file_ = log_to_file; }
52  static void set_output_file_address(bool output_file_address) { output_file_address_ = output_file_address; }
53 
54  static void Log_(const std::string& message);
55  static std::string CurrentDateTime_();
56 
57  private:
58  static std::mutex mutex_;
59  static bool log_to_file_;
60  static std::string output_file_address_;
61 };
62 
63 #endif // ATOM_TOOLS_OUTPUTLOGGER
Definition: output_logger.h:43