2
Copyright (C) 2003-2004 Douglas Thain and the University of Wisconsin
3
Copyright (C) 2005- The University of Notre Dame
4
This software is distributed under the GNU General Public License.
5
See the file COPYING for details.
8
#include "ftsh_error.h"
18
static FILE * error_stream = 0;
19
static int error_level = FTSH_ERROR_FAILURE;
20
static const char * error_name = "unknown";
21
static int decimal_time = 0;
23
void ftsh_error_name( const char *name )
28
void ftsh_error_level( int level )
33
void ftsh_error_stream( FILE *stream )
35
error_stream = stream;
38
void ftsh_error_decimal_time( int onoff )
43
static char * make_prefix( int line )
45
static char txt[1024];
52
sprintf(txt,"%d.%06d [%d] %s:%d",(int)tv.tv_sec,(int)tv.tv_usec,(int)getpid(),error_name,line);
55
sprintf(txt,"%s[%d] %s:%d",ctime(&t),(int)getpid(),error_name,line);
63
static void do_error( int level, int line, const char *fmt, va_list args )
66
error_stream = stderr;
68
if(error_level>=level) {
69
fprintf(error_stream,"%s ",make_prefix(line));
70
vfprintf(error_stream,fmt,args);
71
fprintf(error_stream,"\n");
76
void ftsh_error( int level, int line, const char *fmt, ... )
80
do_error(level,line,fmt,args);
84
void ftsh_fatal( int line, const char *fmt, ... )
88
do_error(error_level,line,fmt,args);