edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
* [Edbrowse-dev] debugging output to a file
@ 2016-01-13  8:57 Karl Dahlke
  2016-01-13 19:05 ` Geoff McLane
  0 siblings, 1 reply; 4+ messages in thread
From: Karl Dahlke @ 2016-01-13  8:57 UTC (permalink / raw)
  To: Edbrowse-dev

A feature that has long been requested.
To send your debugging output to a file, do this.

db>/tmp/h

To go back to stdout,

db>

When sent to a file, messages at level 1 and 2 are still sent to stdout.
Otherwise you wouldn't be able to see what you're doing so to speak.

Debug file is limited to 10 megs.
I wanted some kind of cap on it, because sometimes I am using
debug information to track down an infinite loop.

I use setlinebuf to make sure the log is up to date,
even if the program seg faults.
(This has to be tweaked for windows, no such function.)

This was somewhat tedious, but made easier by the internationalization
of all the messages.
In other words, all the mainstream output vectors through eb_puts(),
so I just add some code in there to tee it over to the debug file if present.
That takes care of the regular output, then the input which is just in one place,
then debugPrint(), and a few more weird situations, and we're there.

Karl Dahlke

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Edbrowse-dev] debugging output to a file
  2016-01-13  8:57 [Edbrowse-dev] debugging output to a file Karl Dahlke
@ 2016-01-13 19:05 ` Geoff McLane
  2016-01-13 19:23   ` Geoff McLane
  0 siblings, 1 reply; 4+ messages in thread
From: Geoff McLane @ 2016-01-13 19:05 UTC (permalink / raw)
  To: edbrowse-dev

Hi Karl,

As you predicted can not compile in windows... missing
'setlinebuf(FILE *file)' ;=((

What exactly does it do?

Since you mention "to make sure the log is up to date",
so is it like a flush?

In a segfault like crash quite often the last lines do not
get to the log... and of course they are usually the lines
we need to see most... but a fflush after a write fix this...
mostly...

Regards,
Geoff.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Edbrowse-dev] debugging output to a file
  2016-01-13 19:05 ` Geoff McLane
@ 2016-01-13 19:23   ` Geoff McLane
  2016-01-16 14:46     ` Adam Thompson
  0 siblings, 1 reply; 4+ messages in thread
From: Geoff McLane @ 2016-01-13 19:23 UTC (permalink / raw)
  To: edbrowse-dev

[-- Attachment #1: Type: text/plain, Size: 971 bytes --]

My patch to get the WIN32 compile -

diff --git a/src/stringfile.c b/src/stringfile.c
index de96f87..ba39f66 100644
--- a/src/stringfile.c
+++ b/src/stringfile.c
@@ -19,7 +19,7 @@
 char emptyString[] = "";
 bool showHiddenFiles, isInteractive;
 int debugLevel = 1;
-FILE *debugFile;
+FILE *debugFile = 0;
 char *downDir, *home;

 /*********************************************************************
@@ -642,9 +642,11 @@ void setDebugFile(const char *name)
  if (!name || !*name)
  return;
  debugFile = fopen(name, "w");
- if (debugFile)
+ if (debugFile) {
+#ifndef _MSC_VER // port setlinebuf(debugFile);, required???
  setlinebuf(debugFile);
- else
+#endif
+    } else
  printf("cannot create %s\n", name);
 } /* setDebugFile */


I do not know if specifically setting the debugFile to 0 is required,
but otherwise there is no guarantee that it starts as a zero... and I
see it tested in a lots of places, maybe before it is otherwise
initialized...

Regards,
Geoff.

[-- Attachment #2: Type: text/html, Size: 2520 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Edbrowse-dev] debugging output to a file
  2016-01-13 19:23   ` Geoff McLane
@ 2016-01-16 14:46     ` Adam Thompson
  0 siblings, 0 replies; 4+ messages in thread
From: Adam Thompson @ 2016-01-16 14:46 UTC (permalink / raw)
  To: Geoff McLane; +Cc: edbrowse-dev

[-- Attachment #1: Type: text/plain, Size: 475 bytes --]

On Wed, Jan 13, 2016 at 08:23:54PM +0100, Geoff McLane wrote:
> I do not know if specifically setting the debugFile to 0 is required,
> but otherwise there is no guarantee that it starts as a zero... and I
> see it tested in a lots of places, maybe before it is otherwise
> initialized...

I think I'd set it to NULL, but yeah it needs to be set.

Can we use another ifdef to do fflush in the relevant functions,
or just use fflush rather than line buffering?

Cheers,
Adam.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-01-16 14:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13  8:57 [Edbrowse-dev] debugging output to a file Karl Dahlke
2016-01-13 19:05 ` Geoff McLane
2016-01-13 19:23   ` Geoff McLane
2016-01-16 14:46     ` Adam Thompson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).