2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1998--2011 Jan Nieuwenhuizen <janneke@gnu.org>
5 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 LilyPond is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 LilyPond is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
23 #include "lily-guile.hh"
24 #include "program-option.hh"
29 Error / warning / progress / debug message output functions
32 LY_DEFINE (ly_error, "ly:error",
33 1, 0, 1, (SCM str, SCM rest),
34 "A Scheme callable function to issue the error @var{str}."
35 " The error is formatted with @code{format} and @var{rest}.")
37 LY_ASSERT_TYPE (scm_is_string, str, 1);
38 str = scm_simple_format (SCM_BOOL_F, str, rest);
39 error (ly_scm2string (str));
40 return SCM_UNSPECIFIED;
43 LY_DEFINE (ly_programming_error, "ly:programming-error",
44 1, 0, 1, (SCM str, SCM rest),
45 "A Scheme callable function to issue the internal warning"
46 " @var{str}. The message is formatted with @code{format}"
49 LY_ASSERT_TYPE (scm_is_string, str, 1);
50 str = scm_simple_format (SCM_BOOL_F, str, rest);
52 if (get_program_option ("warning-as-error"))
53 error (ly_scm2string (str));
55 programming_error (ly_scm2string (str));
57 return SCM_UNSPECIFIED;
60 LY_DEFINE (ly_warning, "ly:warning",
61 1, 0, 1, (SCM str, SCM rest),
62 "A Scheme callable function to issue the warning @var{str}."
63 " The message is formatted with @code{format} and @var{rest}.")
65 LY_ASSERT_TYPE (scm_is_string, str, 1);
66 str = scm_simple_format (SCM_BOOL_F, str, rest);
68 if (get_program_option ("warning-as-error"))
69 error (ly_scm2string (str));
71 warning (ly_scm2string (str));
73 return SCM_UNSPECIFIED;
76 LY_DEFINE (ly_progress, "ly:progress",
77 1, 0, 1, (SCM str, SCM rest),
78 "A Scheme callable function to print progress @var{str}."
79 " The message is formatted with @code{format} and @var{rest}.")
81 LY_ASSERT_TYPE (scm_is_string, str, 1);
82 str = scm_simple_format (SCM_BOOL_F, str, rest);
83 // Calls to ly:progress should in general not start a new line
84 progress_indication (ly_scm2string (str), false);
85 return SCM_UNSPECIFIED;
88 LY_DEFINE (ly_success, "ly:success",
89 1, 0, 1, (SCM str, SCM rest),
90 "A Scheme callable function to issue a success message @var{str}."
91 " The message is formatted with @code{format} and @var{rest}.")
93 LY_ASSERT_TYPE (scm_is_string, str, 1);
94 str = scm_simple_format (SCM_BOOL_F, str, rest);
95 successful (ly_scm2string (str));
96 return SCM_UNSPECIFIED;
99 LY_DEFINE (ly_message, "ly:message",
100 1, 0, 1, (SCM str, SCM rest),
101 "A Scheme callable function to issue the message @var{str}."
102 " The message is formatted with @code{format} and @var{rest}.")
104 LY_ASSERT_TYPE (scm_is_string, str, 1);
105 str = scm_simple_format (SCM_BOOL_F, str, rest);
106 message (ly_scm2string (str));
107 return SCM_UNSPECIFIED;
110 LY_DEFINE (ly_debug, "ly:debug",
111 1, 0, 1, (SCM str, SCM rest),
112 "A Scheme callable function to issue a debug message @var{str}."
113 " The message is formatted with @code{format} and @var{rest}.")
115 // TODO: Add the newline flag!
116 LY_ASSERT_TYPE (scm_is_string, str, 1);
117 str = scm_simple_format (SCM_BOOL_F, str, rest);
118 debug_output (ly_scm2string (str));
119 return SCM_UNSPECIFIED;
122 LY_DEFINE (ly_warning_located, "ly:warning-located",
123 2, 0, 1, (SCM location, SCM str, SCM rest),
124 "A Scheme callable function to issue the warning @var{str} at"
125 " the specified location in an input file."
126 " The message is formatted with @code{format} and @var{rest}.")
128 LY_ASSERT_TYPE (scm_is_string, location, 1);
129 LY_ASSERT_TYPE (scm_is_string, str, 2);
130 str = scm_simple_format (SCM_BOOL_F, str, rest);
132 if (get_program_option ("warning-as-error"))
133 error (ly_scm2string (str), ly_scm2string (location));
135 warning (ly_scm2string (str), ly_scm2string (location));
137 return SCM_UNSPECIFIED;