MatN work for versatile appimage creation for all types of os
[goodguy/cinelerra.git] / cinelerra-5.1 / tools / makeappimagetool / includes / log.h
1 // system includes
2 #include <iostream>
3
4 // library includes
5 #include <boost/filesystem.hpp>
6
7 #pragma once
8
9 namespace linuxdeploy {
10     namespace core {
11         namespace log {
12             enum LD_LOGLEVEL {
13                 LD_DEBUG = 0,
14                 LD_INFO,
15                 LD_WARNING,
16                 LD_ERROR
17             };
18
19             enum LD_STREAM_CONTROL {
20                 LD_NOOP = 0,
21                 LD_NO_SPACE,
22             };
23
24             class ldLog {
25                 private:
26                     // this is the type of std::cout
27                     typedef std::basic_ostream<char, std::char_traits<char> > CoutType;
28
29                     // this is the function signature of std::endl
30                     typedef CoutType& (* stdEndlType)(CoutType&);
31
32                 private:
33                     static LD_LOGLEVEL verbosity;
34
35                 private:
36                     bool prependSpace;
37                     bool logLevelSet;
38                     CoutType& stream = std::cout;
39
40                     LD_LOGLEVEL currentLogLevel;
41
42                 private:
43                     // advanced behavior
44                     ldLog(bool prependSpace, bool logLevelSet, LD_LOGLEVEL logLevel);
45
46                     void checkPrependSpace();
47
48                     bool checkVerbosity();
49
50                 public:
51                     static void setVerbosity(LD_LOGLEVEL verbosity);
52
53                 public:
54                     // public constructor
55                     // does not implement the advanced behavior -- see private constructors for that
56                     ldLog();
57
58                 public:
59                     ldLog operator<<(const std::string& message);
60                     ldLog operator<<(const char* message);
61                     ldLog operator<<(const boost::filesystem::path& path);
62                     ldLog operator<<(const int val);
63                     ldLog operator<<(const size_t val);
64                     ldLog operator<<(const double val);
65                     ldLog operator<<(stdEndlType strm);
66                     ldLog operator<<(const LD_LOGLEVEL logLevel);
67                     ldLog operator<<(const LD_STREAM_CONTROL streamControl);
68
69                     void write(const char* s, const size_t n);
70             };
71         }
72     }
73 }