]> git.donarmstrong.com Git - lilypond.git/blob - flower/include/warn.hh
Proper loglevels: cmd-line option --loglevel=NONE/ERROR/WARN/BASIC/PROGRESS/DEBUG
[lilypond.git] / flower / include / warn.hh
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1997--2011 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef WARN_HH
21 #define WARN_HH
22
23 #include "std-string.hh"
24
25 /* Log-level bitmasks */
26 #define LOG_NONE 0
27 #define LOG_ERROR 1<<0
28 #define LOG_WARN 1<<1
29 #define LOG_BASIC 1<<2  // undocumented basic_progress, i.e. input file name and success
30 #define LOG_PROGRESS 1<<3
31 // Currently, there is no separation between progress and other info messages:
32 #define LOG_INFO 1<<4
33 #define LOG_DEBUG 1<<8
34
35 /* Log-level definitions (or'ed bitmasks) */
36 #define LOGLEVEL_NONE (LOG_NONE)
37 #define LOGLEVEL_ERROR (LOG_ERROR)
38 #define LOGLEVEL_WARN (LOGLEVEL_ERROR | LOG_WARN)
39 #define LOGLEVEL_BASIC (LOGLEVEL_WARN | LOG_BASIC)
40 #define LOGLEVEL_PROGRESS (LOGLEVEL_BASIC | LOG_PROGRESS)
41 // Currently, there is no separation between progress and other info messages:
42 #define LOGLEVEL_INFO (LOGLEVEL_PROGRESS | LOG_INFO)
43 #define LOGLEVEL_DEBUG (LOGLEVEL_INFO | LOG_DEBUG)
44
45 extern int loglevel;
46
47 /* output messages, in decreasing order of importance */
48 void error (string s, string location = ""); // Fatal error, exits lilypond!
49 void programming_error (string s, string location = "");
50 void non_fatal_error (string, string location = "");
51 void warning (string s, string location = "");
52 void successful (string s, string location = "");
53 /* progress_indication does by default *NOT* start on a new line */
54 void progress_indication (string s, bool newline = false, string location = "");
55 void message (string s, bool newline = true, string location = "");
56 void debug_output (string s, bool newline = true, string location = "");
57
58 /* Helper functions that always print out the message. Callers should ensure
59    that the loglevel is obeyed */
60 void print_message (int level, string location, string s, bool newline = true);
61
62 bool is_loglevel (int level);
63 void set_loglevel (int level);
64 void set_loglevel (string level);
65
66 #endif /* WARN_HH */