summaryrefslogtreecommitdiffstats
path: root/lib/output.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/output.c')
-rw-r--r--lib/output.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/output.c b/lib/output.c
index 61fbf832..c408a2f5 100644
--- a/lib/output.c
+++ b/lib/output.c
@@ -13,6 +13,7 @@
13 13
14// == Global variables 14// == Global variables
15static mp_output_format output_format = MP_FORMAT_DEFAULT; 15static mp_output_format output_format = MP_FORMAT_DEFAULT;
16static mp_output_detail_level level_of_detail = MP_DETAIL_ALL;
16 17
17// == Prototypes == 18// == Prototypes ==
18static char *fmt_subcheck_output(mp_output_format output_format, mp_subcheck check, unsigned int indentation); 19static char *fmt_subcheck_output(mp_output_format output_format, mp_subcheck check, unsigned int indentation);
@@ -202,7 +203,12 @@ mp_state_enum mp_compute_subcheck_state(const mp_subcheck check) {
202 } 203 }
203 204
204 mp_subcheck_list *scl = check.subchecks; 205 mp_subcheck_list *scl = check.subchecks;
205 mp_state_enum result = check.default_state; 206
207 if (scl == NULL) {
208 return check.default_state;
209 }
210
211 mp_state_enum result = STATE_OK;
206 212
207 while (scl != NULL) { 213 while (scl != NULL) {
208 result = max_state_alt(result, mp_compute_subcheck_state(scl->subcheck)); 214 result = max_state_alt(result, mp_compute_subcheck_state(scl->subcheck));
@@ -247,7 +253,9 @@ char *mp_fmt_output(mp_check check) {
247 mp_subcheck_list *subchecks = check.subchecks; 253 mp_subcheck_list *subchecks = check.subchecks;
248 254
249 while (subchecks != NULL) { 255 while (subchecks != NULL) {
250 asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_MULTI_LINE, subchecks->subcheck, 1)); 256 if (level_of_detail == MP_DETAIL_ALL || mp_compute_subcheck_state(subchecks->subcheck) != STATE_OK) {
257 asprintf(&result, "%s\n%s", result, fmt_subcheck_output(MP_FORMAT_MULTI_LINE, subchecks->subcheck, 1));
258 }
251 subchecks = subchecks->next; 259 subchecks = subchecks->next;
252 } 260 }
253 261
@@ -539,3 +547,7 @@ parsed_output_format mp_parse_output_format(char *format_string) {
539void mp_set_format(mp_output_format format) { output_format = format; } 547void mp_set_format(mp_output_format format) { output_format = format; }
540 548
541mp_output_format mp_get_format(void) { return output_format; } 549mp_output_format mp_get_format(void) { return output_format; }
550
551void mp_set_level_of_detail(mp_output_detail_level level) { level_of_detail = level; }
552
553mp_output_detail_level mp_get_level_of_detail(void) { return level_of_detail; }