gfx: Implement GP_FillCircleSeg()
[gfxprim.git] / demos / c_simple / debug_handler.c
blob5c472fd61e4f3c68a3968b40a1bdcd69aab32668
1 /*****************************************************************************
2 * This file is part of gfxprim library. *
3 * *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
8 * *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
18 * *
19 * Copyright (C) 2009-2013 Cyril Hrubis <metan@ucw.cz> *
20 * *
21 *****************************************************************************/
25 Example on custom debug message handler.
29 #include <stdio.h>
30 #include <GP.h>
32 static char level_to_c(int level)
34 switch (level) {
35 case GP_DEBUG_TODO:
36 return 'T';
37 case GP_DEBUG_WARN:
38 return 'W';
39 case GP_DEBUG_BUG:
40 return 'B';
41 case GP_DEBUG_FATAL:
42 return 'F';
43 case 0 ... 9:
44 return '0' + level;
45 default:
46 return 'U';
50 void debug_handler(const struct GP_DebugMsg *msg)
52 printf("%c: %s->%s():%u: %s\n", level_to_c(msg->level), msg->file,
53 msg->fn, msg->line, msg->msg);
56 int main(void)
58 /* Set custom debug handler */
59 GP_SetDebugHandler(debug_handler);
61 /* Print some debug messages */
62 GP_WARN("This is a warning");
63 GP_FATAL("This is a fatal condition");
65 /* Turn on verbose debug and call some library functions */
66 GP_SetDebugLevel(10);
68 GP_Pixmap *pixmap = GP_PixmapAlloc(1000, 1000, 1);
70 GP_FilterGaussianBlur(pixmap, pixmap, 10, 10, NULL);
72 GP_PixmapFree(pixmap);
74 return 0;