# HG changeset patch # User Kim F. Storm # Date 1069622904 0 # Node ID 1679881ea8801ff813845a12d7e2fc6f496ba997 # Parent 00845c3bc4e45dd29cbef406d3c1e3c2ebc0a13c (Fredirect_debugging_output): New defun. (syms_of_print): Defsubr it. diff -r 00845c3bc4e4 -r 1679881ea880 src/print.c --- a/src/print.c Sun Nov 23 20:57:47 2003 +0000 +++ b/src/print.c Sun Nov 23 21:28:24 2003 +0000 @@ -911,6 +911,39 @@ return character; } +FILE *initial_stderr_stream = NULL; + +DEFUN ("redirect-debugging-output", Fredirect_debugging_output, Sredirect_debugging_output, + 1, 2, + "FDebug output file: \nP", + doc: /* Redirect debugging output (stderr stream) to file FILE. +If FILE is nil, reset target to the initial stderr stream. +Optional arg APPEND non-nil (interactively, with prefix arg) means +append to existing target file. */) + (file, append) + Lisp_Object file, append; +{ + if (initial_stderr_stream != NULL) + fclose(stderr); + stderr = initial_stderr_stream; + initial_stderr_stream = NULL; + + if (STRINGP (file)) + { + file = Fexpand_file_name (file, Qnil); + initial_stderr_stream = stderr; + stderr = fopen(SDATA (file), NILP (append) ? "w" : "a"); + if (stderr == NULL) + { + stderr = initial_stderr_stream; + initial_stderr_stream = NULL; + report_file_error ("Cannot open debugging output stream", + Fcons (file, Qnil)); + } + } + return Qnil; +} + /* This is the interface for debugging printing. */ void @@ -2164,6 +2197,7 @@ defsubr (&Sterpri); defsubr (&Swrite_char); defsubr (&Sexternal_debugging_output); + defsubr (&Sredirect_debugging_output); Qexternal_debugging_output = intern ("external-debugging-output"); staticpro (&Qexternal_debugging_output);