]> git.lyx.org Git - lyx.git/blob - src/client/debug.h
cleanup some debug messages
[lyx.git] / src / client / debug.h
1 // -*- C++ -*-
2 /**
3  * \file debug.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef LYXDEBUG_H
14 #define LYXDEBUG_H
15
16 #include "support/debugstream.h"
17
18 /** Ideally this should have been a namespace, but since we try to be
19     compilable on older C++ compilators too, we use a class instead.
20     This is all the different debug levels that we have.
21 */
22 class lyx_debug_trait {
23 public:
24         ///
25         enum type {
26                 ///
27                 NONE = 0,
28                 ///
29                 INFO       = (1 << 0),
30                 ///
31                 DEBUG      = (1 << 31),
32                 ///
33                 ANY = 0xffffffff
34         };
35
36         static bool match(type a, type b) {
37                 return (a & b);
38         }
39
40         /** A function to convert symbolic string names on debug levels
41             to their numerical value.
42         */
43         static type value(std::string const & val);
44
45         /** Display the tags and descriptions of the current debug level
46             of ds
47         */
48         static void showLevel(std::ostream & o, type level);
49
50         /** show all the possible tags that can be used for debugging */
51         static void showTags(std::ostream & o);
52
53 };
54
55
56
57 inline
58 void operator|=(lyx_debug_trait::type & d1, lyx_debug_trait::type d2)
59 {
60         d1 = static_cast<lyx_debug_trait::type>(d1 | d2);
61 }
62
63
64 // std::ostream & operator<<(std::ostream & o, Debug::type t);
65
66 typedef basic_debugstream<lyx_debug_trait> LyXErr;
67 typedef LyXErr::debug Debug;
68
69 extern LyXErr lyxerr;
70
71 #endif