summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-26 08:30:37 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-09-26 08:34:39 -0700
commit5305fb152b5cb31e81ac3f1ca2f2782d20b8bb83 (patch)
tree585f602f43c4a56880f469615b5a080b470fb273 /main.c
parentc4c636fb4ffa942f282d57556a579de311b96c43 (diff)
downloadsubsurface-5305fb152b5cb31e81ac3f1ca2f2782d20b8bb83.tar.gz
Add the ability to create a log file for debugging output
Especially when asking non-developers for help debugging a problem it can be extremely useful to have debugging output not go to the console but to a log file instead. This just adds the infrastructure to create (and close) such a file. No changes to the debug output are made. All this is of course #ifdef'ed out. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'main.c')
-rw-r--r--main.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/main.c b/main.c
index d3bd44335..95f63713d 100644
--- a/main.c
+++ b/main.c
@@ -7,6 +7,11 @@
#include "dive.h"
#include "divelist.h"
+#ifdef DEBUGFILE
+char *debugfilename;
+FILE *debugfile;
+#endif
+
struct units output_units;
/* random helper functions, used here or elsewhere */
@@ -222,6 +227,13 @@ int main(int argc, char **argv)
init_ui(&argc, &argv);
+#ifdef DEBUGFILE
+ debugfilename = (char *)subsurface_default_filename();
+ strncpy(debugfilename + strlen(debugfilename) - 3, "log", 3);
+ if (g_mkdir_with_parents(g_path_get_dirname(debugfilename), 0664) != 0 ||
+ (debugfile = g_fopen(debugfilename, "w")) == NULL)
+ printf("oh boy, can't create debugfile");
+#endif
for (i = 1; i < argc; i++) {
const char *a = argv[i];
@@ -256,5 +268,9 @@ int main(int argc, char **argv)
parse_xml_exit();
+#ifdef DEBUGFILE
+ if (debugfile)
+ fclose(debugfile);
+#endif
return 0;
}