Mercurial > hg > fxanalyse
comparison logging.c @ 199:111610d871af
Show error state in main user inteface panel
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Mon, 31 Mar 2014 17:03:37 +0200 |
parents | 0fed60877099 |
children | 28a56e4c06a4 |
comparison
equal
deleted
inserted
replaced
198:5cac684eb12e | 199:111610d871af |
---|---|
5 #include "config.h" | 5 #include "config.h" |
6 #include "logging.h" | 6 #include "logging.h" |
7 | 7 |
8 /* this refers to the event time defined as a global variable in the main program */ | 8 /* this refers to the event time defined as a global variable in the main program */ |
9 extern double utc; | 9 extern double utc; |
10 /* main panel id */ | |
11 extern unsigned int MainPanel; | |
10 | 12 |
11 | 13 |
12 int __logger_init(struct logger *l) | 14 int __logger_init(struct logger *l, void(*onerror)(int, const char *)) |
13 { | 15 { |
14 int rv, panel; | 16 int rv, panel; |
15 char path[MAX_PATHNAME_LEN], *filename; | 17 char path[MAX_PATHNAME_LEN], *filename; |
16 | 18 |
19 l->onerror = onerror; | |
17 l->fd = -1; | 20 l->fd = -1; |
18 | 21 |
19 panel = LoadPanel(0, "FXAnalyse.uir", LOGGING); | 22 panel = LoadPanel(0, "FXAnalyse.uir", LOGGING); |
20 if (panel < 0) | 23 if (panel < 0) |
21 return -1; | 24 return -1; |
76 msg[len] = '\0'; | 79 msg[len] = '\0'; |
77 | 80 |
78 /* display message */ | 81 /* display message */ |
79 SetCtrlVal(l->panel, LOGGING_LOGGING, msg); | 82 SetCtrlVal(l->panel, LOGGING_LOGGING, msg); |
80 | 83 |
84 /* report error */ | |
85 if (level == ERROR) | |
86 l->onerror(level, msg); | |
87 | |
81 /* write to log file */ | 88 /* write to log file */ |
82 if (l->fd >= 0) | 89 if (l->fd >= 0) |
83 write(l->fd, msg, len); | 90 write(l->fd, msg, len); |
84 } | 91 } |