1 // SPDX-License-Identifier: GPL-2.0
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
)
18 fprintf(stderr
, "Warning:\n");
19 vfprintf(stderr
, format
, args
);
23 static struct perf_error_ops default_eops
=
25 .error
= perf_stdio__error
,
26 .warning
= perf_stdio__warning
,
29 static struct perf_error_ops
*perf_eops
= &default_eops
;
32 int ui__error(const char *format
, ...)
37 va_start(args
, format
);
38 ret
= perf_eops
->error(format
, args
);
44 int ui__warning(const char *format
, ...)
49 va_start(args
, format
);
50 ret
= perf_eops
->warning(format
, args
);
57 * perf_error__register - Register error logging functions
58 * @eops: The pointer to error logging function struct
60 * Register UI-specific error logging functions. Before calling this,
61 * other logging functions should be unregistered, if any.
63 int perf_error__register(struct perf_error_ops
*eops
)
65 if (perf_eops
!= &default_eops
)
73 * perf_error__unregister - Unregister error logging functions
74 * @eops: The pointer to error logging function struct
76 * Unregister already registered error logging functions.
78 int perf_error__unregister(struct perf_error_ops
*eops
)
80 if (perf_eops
!= eops
)
83 perf_eops
= &default_eops
;