1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4     Rosegarden
5     A sequencer and musical notation editor.
6     Copyright 2000-2021 the Rosegarden development team.
7     See the AUTHORS file for more details.
8 
9     This program is free software; you can redistribute it and/or
10     modify it under the terms of the GNU General Public License as
11     published by the Free Software Foundation; either version 2 of the
12     License, or (at your option) any later version.  See the file
13     COPYING included with this distribution for more information.
14 */
15 
16 #pragma once
17 
18 #include <QDebug>
19 #include <QTextStream>
20 
21 #include <string>
22 
23 #include <rosegardenprivate_export.h>
24 
25 
26 namespace Rosegarden
27 {
28 
29 
30 ROSEGARDENPRIVATE_EXPORT QDebug &operator<<(QDebug &, const std::string &);
31 
32 class RGNoDebug
33 {
34 public:
35     template <typename T>
36     RGNoDebug &operator<<(const T &)  { return *this; }
37 
38     RGNoDebug &operator<<(QTextStreamFunction)  { return *this; }
39 };
40 
41 #if !defined RG_MODULE_STRING
42     #define RG_MODULE_STRING "[generic] "
43 #endif
44 
45 #if !defined NDEBUG
46 
47     // Use RG_INFO for startup/shutdown progress messages that will be helpful
48     // when debugging issues with users.  These will always be written to
49     // the debug output even with RG_NO_DEBUG_PRINT defined.  Keep them
50     // to a minimum.
51     #define RG_INFO QDebug(QtDebugMsg) << RG_MODULE_STRING
52 
53 #else
54 
55     #define RG_INFO Rosegarden::RGNoDebug() << RG_MODULE_STRING
56 
57 #endif
58 
59 #if !defined NDEBUG && !defined RG_NO_DEBUG_PRINT
60 
61     // Use RG_DEBUG for general debugging.  Define RG_NO_DEBUG_PRINT at the
62     // top of a .cpp to turn off all RG_DEBUG output.
63     #define RG_DEBUG QDebug(QtDebugMsg) << RG_MODULE_STRING
64 
65     // !!! The following are deprecated since RG_MODULE_STRING provides more
66     //     information.  Define RG_MODULE_STRING and use RG_DEBUG instead.
67     #define NOTATION_DEBUG  QDebug(QtDebugMsg) << "[notation] "
68     #define MATRIX_DEBUG    QDebug(QtDebugMsg) << "[matrix] "
69     #define SEQUENCER_DEBUG QDebug(QtDebugMsg) << "[sequencer] "
70 
71 #else
72 
73     #define RG_DEBUG Rosegarden::RGNoDebug()
74 
75     // !!! Deprecated.
76     #define NOTATION_DEBUG  Rosegarden::RGNoDebug()
77     #define MATRIX_DEBUG    Rosegarden::RGNoDebug()
78     #define SEQUENCER_DEBUG Rosegarden::RGNoDebug()
79 
80 #endif
81 
82 // Use RG_WARNING for recoverable errors that shouldn't usually occur, but
83 // we want to know about them when debugging issues with users.  These will
84 // always be written to the debug output even with RG_NO_DEBUG_PRINT defined.
85 // For a normal run, there should be no RG_WARNING output.
86 // This works in both debug and release builds.  Formerly, std::cerr was
87 // used for this.
88 #define RG_WARNING QDebug(QtDebugMsg) << RG_MODULE_STRING
89 
90 // Handy logging switcher.  Repurpose when needed in the future.
91 //extern bool bug1560Logging();
92 
93 
94 }
95