Mercurial > hg > fxanalyse
comparison logging.c @ 229:28a56e4c06a4
Improvements to log file handling
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Mon, 27 Oct 2014 17:48:22 +0100 |
parents | 111610d871af |
children | ec81395bf08d |
comparison
equal
deleted
inserted
replaced
228:5e69d9abbbf2 | 229:28a56e4c06a4 |
---|---|
1 #include <ansi_c.h> | 1 #include <ansi_c.h> |
2 #include <inifile.h> | 2 #include <inifile.h> |
3 #include <lowlvlio.h> | 3 #include <lowlvlio.h> |
4 #include <ansi_c.h> | |
4 | 5 |
5 #include "config.h" | 6 #include "config.h" |
6 #include "logging.h" | 7 #include "logging.h" |
7 | 8 |
8 /* this refers to the event time defined as a global variable in the main program */ | 9 /* this refers to the event time defined as a global variable in the main program */ |
31 IniText configuration = Ini_New(TRUE); | 32 IniText configuration = Ini_New(TRUE); |
32 Ini_ReadFromFile(configuration, path); | 33 Ini_ReadFromFile(configuration, path); |
33 | 34 |
34 /* logging file name */ | 35 /* logging file name */ |
35 rv = Ini_GetStringCopy(configuration, "logging", "filename", &filename); | 36 rv = Ini_GetStringCopy(configuration, "logging", "filename", &filename); |
36 if (rv > 0) | 37 if (rv > 0) { |
38 __logmessage(l, INFO, "logging to '%s'", filename); | |
37 l->fd = open(filename, O_CREAT|O_WRONLY|O_APPEND, 00744); | 39 l->fd = open(filename, O_CREAT|O_WRONLY|O_APPEND, 00744); |
40 if (l->fd < 0) | |
41 __logmessage(l, ERROR, "open log file %s: %s", filename, strerror(errno)); | |
42 } | |
38 | 43 |
39 free(filename); | 44 free(filename); |
40 Ini_Dispose(configuration); | 45 Ini_Dispose(configuration); |
41 | 46 |
42 return 0; | 47 return 0; |