summaryrefslogtreecommitdiff
blob: 9e955f8353d911675069b8a5f1fd79c88dd3aed0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "memento.h"
#include "outf.h"

#include <stdarg.h>
#include <stdio.h>
#include <string.h>

int extract_outf_verbose = 0;

void extract_outf_verbose_set(int verbose)
{
    extract_outf_verbose = verbose;
}

void (extract_outf)(
        int         level,
        const char* file,
        int         line,
        const char* fn,
        int         ln,
        const char* format,
        ...
        )
{
    va_list va;
    if (level > extract_outf_verbose) {
        return;
    }

    if (ln) {
        fprintf(stderr, "%s:%i:%s: ", file, line, fn);
    }
    va_start(va, format);
    vfprintf(stderr, format, va);
    va_end(va);
    if (ln) {
        size_t len = strlen(format);
        if (len == 0 || format[len-1] != '\n') {
            fprintf(stderr, "\n");
        }
    }
}