Skip to content
Snippets Groups Projects
Commit ef6cb876 authored by Rene Brun's avatar Rene Brun
Browse files

From Valeriy Onuchin:

- I introduced debugPrint function which
  prints debugging message to stderr and to the system debugger under Windows.

Printing to the system debugger is usfull for debugging pure GUI (without console)
appications under MS Windows.


git-svn-id: http://root.cern.ch/svn/root/trunk@8053 27541ba8-7e3a-0410-8455-c3a389f83636
parent d5e044fe
No related branches found
No related tags found
No related merge requests found
// @(#)root/base:$Name: $:$Id: TError.cxx,v 1.5 2002/11/18 23:02:19 rdm Exp $
// @(#)root/base:$Name: $:$Id: TError.cxx,v 1.6 2004/01/14 07:41:03 rdm Exp $
// Author: Fons Rademakers 29/07/95
/*************************************************************************
......@@ -21,6 +21,10 @@
// //
//////////////////////////////////////////////////////////////////////////
#ifdef WIN32
#include <windows.h>
#endif
#include <stdio.h>
#include "snprintf.h"
......@@ -36,6 +40,42 @@ const char *kCheckMsg = "%s not true at line %d of `%s'";
static ErrorHandlerFunc_t gErrorHandler = DefaultErrorHandler;
//______________________________________________________________________________
static void debugPrint(const char *fmt, ...)
{
// print debugging message to stderr and to the system debugger under Windows
static Int_t buf_size = 2048;
static char *buf = 0;
char *bp;
va_list arg_ptr;
va_start(arg_ptr, fmt);
again:
if (!buf)
buf = new char[buf_size];
int n = vsnprintf(buf, buf_size, fmt, arg_ptr);
if (n == -1 || n >= buf_size) {
buf_size *= 2;
delete [] buf;
buf = 0;
goto again;
}
va_end(arg_ptr);
fprintf(stderr, "%s", buf);
#ifdef WIN32
::OutputDebugString(buf);
#endif
}
//______________________________________________________________________________
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
{
......@@ -79,15 +119,15 @@ void DefaultErrorHandler(int level, Bool_t abort, const char *location, const ch
type = "Fatal";
if (level >= kBreak && level < kSysError)
fprintf(stderr, "%s %s\n", type, msg);
debugPrint("%s %s\n", type, msg);
else if (!location || strlen(location) == 0)
fprintf(stderr, "%s: %s\n", type, msg);
else
fprintf(stderr, "%s in <%s>: %s\n", type, location, msg);
debugPrint("%s: %s\n", type, msg);
else
debugPrint("%s in <%s>: %s\n", type, location, msg);
fflush(stderr);
if (abort) {
fprintf(stderr, "aborting\n");
debugPrint("aborting\n");
fflush(stderr);
if (gSystem) {
gSystem->StackTrace();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment