~ubuntu-branches/ubuntu/trusty/lifelines/trusty

« back to all changes in this revision

Viewing changes to src/stdlib/errlog.c

  • Committer: Bazaar Package Importer
  • Author(s): Felipe Augusto van de Wiel (faw)
  • Date: 2007-05-23 23:49:53 UTC
  • mfrom: (3.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20070523234953-ogno9rnbmth61i7p
Tags: 3.0.50-2etch1
* Changing docs/ll-reportmanual.xml and docs/ll-userguide.xml to fix
  documentation build problems (Closes: #418347).

* lifelines-reports
  - Adding a dependency to lifelines >= 3.0.50 to prevent file conflict.
    (Closes: #405500).

* Updating French translation. Thanks to Bernard Adrian. (Closes: #356671).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* 
 
2
   Copyright (c) 2005 Perry Rapp
 
3
   "The X11 License"
 
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.
 
7
*/
 
8
/*=============================================================
 
9
 * errlog.c -- Routines for writing to crash log
 
10
 *==============================================================*/
 
11
 
 
12
#include "llstdlib.h"
 
13
/* llstdlib.h pulls in standard.h, config.h, sys_inc.h */
 
14
#ifndef INCLUDED_STDARG_H
 
15
#include <stdarg.h>
 
16
#define INCLUDED_STDARG_H
 
17
#endif
 
18
 
 
19
/*********************************************
 
20
 * local variables
 
21
 *********************************************/
 
22
 
 
23
static char f_crashfile[MAXPATHLEN]="";
 
24
static char f_currentdb[MAXPATHLEN]="";
 
25
 
 
26
/*********************************************
 
27
 * local & exported function definitions
 
28
 * body of module
 
29
 *********************************************/
 
30
 
 
31
/*===============================
 
32
 * errlog_out -- Send message to log file (if one exists)
 
33
 *=============================*/
 
34
void
 
35
errlog_out (CNSTRING title, CNSTRING msg, CNSTRING file, int line)
 
36
{
 
37
        /* avoid reentrancy */
 
38
        static BOOLEAN failing=FALSE;
 
39
        if (failing) return;
 
40
        failing=TRUE;
 
41
 
 
42
        /* send to error log if one is specified */
 
43
        if (f_crashfile[0]) {
 
44
                FILE * fp = fopen(f_crashfile, LLAPPENDTEXT);
 
45
                if (fp) {
 
46
                        LLDATE creation;
 
47
                        get_current_lldate(&creation);
 
48
                        if (title) {
 
49
                                fprintf(fp, "\n%s: %s\n", title, creation.datestr);
 
50
                                if (msg && msg[0]) {
 
51
                                        fprintf(fp, "    %s\n", msg);
 
52
                                }
 
53
                        } else {
 
54
                                if (msg && msg[0]) {
 
55
                                        fprintf(fp, "%s: %s\n", creation.datestr, msg);
 
56
                                } else {
 
57
                                        fprintf(fp, "%s\n", creation.datestr);
 
58
                                }
 
59
                        }
 
60
                        if (line>=1 && file && file[0])
 
61
                                fprintf(fp, _("    in file <%s> at line %d\n"), file, line);
 
62
                        if (f_currentdb[0])
 
63
                                fprintf(fp, "    %s: %s\n", _("Current database"), f_currentdb);
 
64
                        fclose(fp);
 
65
                }
 
66
        }
 
67
        failing=FALSE;
 
68
}
 
69
/*===============================
 
70
 * crash_setcrashlog -- specify where to log alloc messages
 
71
 *=============================*/
 
72
void
 
73
crash_setcrashlog (STRING crashlog)
 
74
{
 
75
        if (!crashlog)
 
76
                crashlog = "";
 
77
        llstrncpy(f_crashfile, crashlog, sizeof(f_crashfile), uu8);
 
78
}
 
79
/*===============================
 
80
 * crash_setdb -- record current database in case of a crash
 
81
 * Created: 2002/06/16, Perry Rapp
 
82
 *=============================*/
 
83
void
 
84
crash_setdb (STRING dbname)
 
85
{
 
86
        if (!dbname)
 
87
                dbname = "";
 
88
        llstrncpy(f_currentdb, dbname, sizeof(f_currentdb), 0);
 
89
}