2
Copyright (c) 2005 Perry Rapp
4
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
/*=============================================================
9
* errlog.c -- Routines for writing to crash log
10
*==============================================================*/
13
/* llstdlib.h pulls in standard.h, config.h, sys_inc.h */
14
#ifndef INCLUDED_STDARG_H
16
#define INCLUDED_STDARG_H
19
/*********************************************
21
*********************************************/
23
static char f_crashfile[MAXPATHLEN]="";
24
static char f_currentdb[MAXPATHLEN]="";
26
/*********************************************
27
* local & exported function definitions
29
*********************************************/
31
/*===============================
32
* errlog_out -- Send message to log file (if one exists)
33
*=============================*/
35
errlog_out (CNSTRING title, CNSTRING msg, CNSTRING file, int line)
37
/* avoid reentrancy */
38
static BOOLEAN failing=FALSE;
42
/* send to error log if one is specified */
44
FILE * fp = fopen(f_crashfile, LLAPPENDTEXT);
47
get_current_lldate(&creation);
49
fprintf(fp, "\n%s: %s\n", title, creation.datestr);
51
fprintf(fp, " %s\n", msg);
55
fprintf(fp, "%s: %s\n", creation.datestr, msg);
57
fprintf(fp, "%s\n", creation.datestr);
60
if (line>=1 && file && file[0])
61
fprintf(fp, _(" in file <%s> at line %d\n"), file, line);
63
fprintf(fp, " %s: %s\n", _("Current database"), f_currentdb);
69
/*===============================
70
* crash_setcrashlog -- specify where to log alloc messages
71
*=============================*/
73
crash_setcrashlog (STRING crashlog)
77
llstrncpy(f_crashfile, crashlog, sizeof(f_crashfile), uu8);
79
/*===============================
80
* crash_setdb -- record current database in case of a crash
81
* Created: 2002/06/16, Perry Rapp
82
*=============================*/
84
crash_setdb (STRING dbname)
88
llstrncpy(f_currentdb, dbname, sizeof(f_currentdb), 0);