1 // SPDX-License-Identifier: GPL-2.0
3 #include "../util/debug.h"
7 * Default error logging functions
9 static int perf_stdio__error(const char *format
, va_list args
)
11 fprintf(stderr
, "Error:\n");
12 vfprintf(stderr
, format
, args
);
16 static int perf_stdio__warning(const char *format
, va_list args
)
21 fprintf(stderr
, "Warning:\n");
22 vfprintf(stderr
, format
, args
);
26 static struct perf_error_ops default_eops
=
28 .error
= perf_stdio__error
,
29 .warning
= perf_stdio__warning
,
32 static struct perf_error_ops
*perf_eops
= &default_eops
;
35 int ui__error(const char *format
, ...)
40 va_start(args
, format
);
41 ret
= perf_eops
->error(format
, args
);
47 int ui__warning(const char *format
, ...)
54 va_start(args
, format
);
55 ret
= perf_eops
->warning(format
, args
);
62 * perf_error__register - Register error logging functions
63 * @eops: The pointer to error logging function struct
65 * Register UI-specific error logging functions. Before calling this,
66 * other logging functions should be unregistered, if any.
68 int perf_error__register(struct perf_error_ops
*eops
)
70 if (perf_eops
!= &default_eops
)
78 * perf_error__unregister - Unregister error logging functions
79 * @eops: The pointer to error logging function struct
81 * Unregister already registered error logging functions.
83 int perf_error__unregister(struct perf_error_ops
*eops
)
85 if (perf_eops
!= eops
)
88 perf_eops
= &default_eops
;