Mercurial > hg
changeset 378:2e6c7b1440d1
Improve debugging/logging
* Tell the user when the tracelog file can't be open
* Only include logprint.h when screen.h is not needed
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Tue, 26 Jul 2005 18:33:22 +0100 |
parents | 00809e3e327e |
children | 57474402997d |
files | mcabber/src/histolog.c mcabber/src/hooks.c mcabber/src/settings.c mcabber/src/utils.c |
diffstat | 4 files changed, 12 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mcabber/src/histolog.c Tue Jul 26 18:18:30 2005 +0100 +++ b/mcabber/src/histolog.c Tue Jul 26 18:33:22 2005 +0100 @@ -30,8 +30,8 @@ #include "histolog.h" #include "hbuf.h" #include "jabglue.h" -#include "screen.h" #include "utils.h" +#include "logprint.h" static guint UseFileLogging; static guint FileLoadLogs;
--- a/mcabber/src/hooks.c Tue Jul 26 18:18:30 2005 +0100 +++ b/mcabber/src/hooks.c Tue Jul 26 18:33:22 2005 +0100 @@ -21,9 +21,9 @@ #include <sys/types.h> #include <unistd.h> -#include <screen.h> #include "hooks.h" +#include "screen.h" #include "roster.h" #include "histolog.h" #include "utf8.h"
--- a/mcabber/src/settings.c Tue Jul 26 18:18:30 2005 +0100 +++ b/mcabber/src/settings.c Tue Jul 26 18:33:22 2005 +0100 @@ -26,7 +26,7 @@ #include "settings.h" #include "commands.h" #include "utils.h" -#include "screen.h" +#include "logprint.h" static GSList *option; static GSList *alias;
--- a/mcabber/src/utils.c Tue Jul 26 18:18:30 2005 +0100 +++ b/mcabber/src/utils.c Tue Jul 26 18:33:22 2005 +0100 @@ -31,7 +31,7 @@ #include <sys/stat.h> #include <config.h> -#include "screen.h" +#include "logprint.h" static int DebugEnabled; static char *FName; @@ -63,7 +63,10 @@ DebugEnabled = level; fp = fopen(FName, "a"); - if (!fp) return; + if (!fp) { + fprintf(stderr, "ERROR: Cannot open tracelog file\n"); + return; + } fprintf(fp, "New trace log started.\n" "----------------------\n"); fchmod(fileno(fp), S_IRUSR|S_IWUSR); @@ -77,7 +80,10 @@ if (((DebugEnabled == 2) && (flag & (LPRINT_LOG|LPRINT_DEBUG))) || ((DebugEnabled == 1) && (flag & LPRINT_LOG))) { FILE *fp = fopen(FName, "a+"); - if (!fp) return; + if (!fp) { + scr_LogPrint(LPRINT_NORMAL, "ERROR: Cannot open tracelog file"); + return; + } fputs(data, fp); fclose(fp); }