aboutsummaryrefslogtreecommitdiff
path: root/util/fbcompose/Logging.hh
diff options
context:
space:
mode:
Diffstat (limited to 'util/fbcompose/Logging.hh')
-rw-r--r--util/fbcompose/Logging.hh103
1 files changed, 103 insertions, 0 deletions
diff --git a/util/fbcompose/Logging.hh b/util/fbcompose/Logging.hh
new file mode 100644
index 0000000..3d04759
--- /dev/null
+++ b/util/fbcompose/Logging.hh
@@ -0,0 +1,103 @@
1/** Logging.hh file for the fluxbox compositor. */
2
3// Copyright (c) 2011 Gediminas Liktaras (gliktaras at gmail dot com)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a copy
6// of this software and associated documentation files (the "Software"), to deal
7// in the Software without restriction, including without limitation the rights
8// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9// copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21// THE SOFTWARE.
22
23
24#ifndef FBCOMPOSITOR_LOGGING_HH
25#define FBCOMPOSITOR_LOGGING_HH
26
27#include <iostream>
28
29
30namespace FbCompositor {
31
32 /** Logging level 0. No messages will be printed. */
33 const int LOG_LEVEL_NONE = 0;
34
35 /** Logging level 1. Only the error messages will be printed. */
36 const int LOG_LEVEL_ERROR = 1;
37
38 /** Logging level 2. Level 1 and warning messages will be printed. */
39 const int LOG_LEVEL_WARN = 2;
40
41 /** Logging level 3. Level 2 and information messages will be printed. */
42 const int LOG_LEVEL_INFO = 3;
43
44 /** Logging level 4. Level 3 and debug messages will be printed. */
45 const int LOG_LEVEL_DEBUG = 4;
46
47 /** Logging level 5. Level 4 and dump messages will be printed. */
48 const int LOG_LEVEL_DEBUG_DUMP = 5;
49
50
51 /**
52 * The log manager class.
53 */
54 class Logger {
55 public :
56 //--- MAIN METHODS -----------------------------------------------------
57
58 /** \returns the current logging level. */
59 static int loggingLevel();
60
61 /** Sets a new logging level. */
62 static void setLoggingLevel(int new_level);
63
64
65 private :
66 //--- CONSTRUCTORS -----------------------------------------------------
67
68 /** Default constructor. */
69 Logger();
70
71 /** Copy constructor. */
72 Logger(const Logger&);
73
74 /** Assignment operator. */
75 Logger &operator=(const Logger&);
76
77
78 //--- PRIVATE VARIABLES ------------------------------------------------
79
80 /** The logging level. */
81 static int m_level;
82 };
83
84}
85
86
87#define fbLog_error fbLog_internal(FbCompositor::LOG_LEVEL_ERROR, "[Error] ")
88#define fbLog_warn fbLog_internal(FbCompositor::LOG_LEVEL_WARN, "[Warn] ")
89#define fbLog_info fbLog_internal(FbCompositor::LOG_LEVEL_INFO, "[Info] ")
90
91#ifdef DEBUG
92 #define fbLog_debug fbLog_internal(FbCompositor::LOG_LEVEL_DEBUG, "[Debug] ")
93 #define fbLog_debugDump fbLog_internal(FbCompositor::LOG_LEVEL_DEBUG_DUMP, "[Dump] ")
94#else
95 #define fbLog_debug if (0) std::cerr
96 #define fbLog_debugDump if (0) std::cerr
97#endif // DEBUG
98
99// Do not call directly!
100#define fbLog_internal(minLevel, levelName) if (FbCompositor::Logger::loggingLevel() >= (minLevel)) std::cerr << (levelName)
101
102
103#endif // FBCOMPOSITOR_LOGGING_HH