mightymandel
v16
GPU-based Mandelbrot set explorer
logging.h
Go to the documentation of this file.
1
// mightymandel -- GPU-based Mandelbrot Set explorer
2
// Copyright (C) 2012,2013,2014,2015 Claude Heiland-Allen
3
// License GPL3+ http://www.gnu.org/licenses/gpl.html
4
5
#ifndef LOGGING_H
6
#define LOGGING_H 1
7
8
#include <assert.h>
9
#include <stdio.h>
10
#include <mpfr.h>
11
12
#include "
mightymandel.h
"
13
14
enum
log_level_t
{
15
LOG_OOPS
= 0,
16
LOG_FATAL
= 1,
17
LOG_ERROR
= 2,
18
LOG_WARN
= 3,
19
LOG_NOTICE
= 4,
20
LOG_INFO
= 5,
21
LOG_DEBUG
= 6
22
};
23
24
extern
enum
log_level_t
log_level
;
25
extern
FILE *
log_target
;
26
extern
const
char
*
log_prefix
[7];
27
28
// Use assert() instead of LOG_FATAL when it's caused by a programming error.
29
// The assertion failure triggers an abort which is catchable in a debugger
30
// like gdb, allowing inspecting the state of the program to diagnose how the
31
// error manifested itself in more detail without having to add extra debug log
32
// message.
33
34
#define log_message(level, ...) do{ if (level <= log_level) { assert(log_target); if (level <= LOG_DEBUG) fprintf(log_target, "%s", log_prefix[level]); mpfr_fprintf(log_target, __VA_ARGS__); } }while(0)
35
36
#ifdef MIGHTYMANDEL_DEBUG
37
#define debug_message(...) log_message(LOG_DEBUG, __VA_ARGS__)
38
#else
39
#define debug_message(...) do{}while(0)
40
#endif
41
42
enum
result_t
{
43
result_ok
= 0,
44
result_glitch
= 1,
45
result_parse
= 2,
46
result_deep
= 3,
47
result_timeout
= 4
48
};
49
50
extern
const
char
*
result_name
[5];
51
52
void
log_result
(
const
char
*
filename
,
enum
result_t
result,
enum
render_method_t
method,
double
iterations,
double
exterior,
double
interior,
double
glitch,
int
passes);
53
54
#endif
src
logging.h
Generated on Mon Jan 19 2015 16:18:12 for mightymandel by
1.8.1.2