• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright(c) 2015 Gabi Melman.
3 // Distributed under the MIT License (http://opensource.org/licenses/MIT)
4 //
5 #pragma once
6 
7 #include <../Utility/GmmLog/spdlog/common.h>
8 #include <../Utility/GmmLog/spdlog/details/log_msg.h>
9 
10 #include <string>
11 
12 // Line logger class - aggregates operator<< calls to fast ostream
13 // and logs upon destruction
14 
15 namespace spdlog
16 {
17 
18 // Forward declaration
19 class logger;
20 
21 namespace details
22 {
23 class line_logger
24 {
25 public:
26     line_logger(logger* callback_logger, level::level_enum msg_level, bool enabled);
27 
28     // No copy intended. Only move
29     line_logger(const line_logger& other) = delete;
30     line_logger& operator=(const line_logger&) = delete;
31     line_logger& operator=(line_logger&&) = delete;
32 
33 
34     line_logger(line_logger&& other);
35 
36     //Log the log message using the callback logger
37     ~line_logger();
38 
39     //
40     // Support for format string with variadic args
41     //
42 
43 
44     void write(const char* what);
45 
46     template <typename... Args>
47     void write(const char* fmt, const Args&... args);
48 
49     //
50     // Support for operator<<
51     //
52     line_logger& operator<<(const char* what);
53     line_logger& operator<<(const std::string& what);
54     line_logger& operator<<(int what);
55     line_logger& operator<<(unsigned int what);
56     line_logger& operator<<(long what);
57     line_logger& operator<<(unsigned long what);
58     line_logger& operator<<(long long what);
59     line_logger& operator<<(unsigned long long what);
60     line_logger& operator<<(double what);
61     line_logger& operator<<(long double what);
62     line_logger& operator<<(float what);
63     line_logger& operator<<(char what);
64     //Support user types which implements operator<<
65     template<typename T>
66     line_logger& operator<<(const T& what);
67 
68     void disable();
69     bool is_enabled() const;
70 
71 private:
72     logger* _callback_logger;
73     log_msg _log_msg;
74     bool _enabled;
75 };
76 } //Namespace details
77 } // Namespace spdlog
78 
79