Tizen 2.0 Release
[framework/multimedia/gst-plugins-bad0.10.git] / gst / nsf / log.c
1 /*
2 ** Nofrendo (c) 1998-2000 Matthew Conte (matt@conte.com)
3 **
4 **
5 ** This program is free software; you can redistribute it and/or
6 ** modify it under the terms of version 2 of the GNU Library General 
7 ** Public License as published by the Free Software Foundation.
8 **
9 ** This program is distributed in the hope that it will be useful, 
10 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
12 ** Library General Public License for more details.  To obtain a 
13 ** copy of the GNU Library General Public License, write to the Free 
14 ** Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
15 **
16 ** Any permitted reproduction of these routines, in whole or in part,
17 ** must bear this legend.
18 **
19 **
20 ** log.c
21 **
22 ** Error logging functions
23 ** $Id$
24 */
25
26 #include <stdio.h>
27 #include <stdarg.h>
28 #include "types.h"
29 #include "log.h"
30
31
32 #ifdef OSD_LOG
33 #include "osd.h"
34 #endif
35
36 #if defined(OSD_LOG) && !defined(NOFRENDO_DEBUG)
37 #error NOFRENDO_DEBUG must be defined as well as OSD_LOG
38 #endif
39
40 /* Note that all of these functions will be empty if
41 ** debugging is not enabled.
42 */
43 #ifdef NOFRENDO_DEBUG
44 static FILE *errorlog;
45 #endif
46
47 int
48 log_init (void)
49 {
50 #ifdef NOFRENDO_DEBUG
51 #ifdef OSD_LOG
52   /* Initialize an OSD logging system */
53   osd_loginit ();
54 #endif /* OSD_LOG */
55   errorlog = fopen ("errorlog.txt", "wt");
56   if (NULL == errorlog)
57     return (-1);
58 #endif /* NOFRENDO_DEBUG */
59   return 0;
60 }
61
62 void
63 log_shutdown (void)
64 {
65 #ifdef NOFRENDO_DEBUG
66   /* Snoop around for unallocated blocks */
67   mem_checkblocks ();
68   mem_checkleaks ();
69 #ifdef OSD_LOG
70   osd_logshutdown ();
71 #endif /* OSD_LOG */
72   fclose (errorlog);
73 #endif /* NOFRENDO_DEBUG */
74 }
75
76 void
77 log_print (const char *string)
78 {
79 #ifdef NOFRENDO_DEBUG
80 #ifdef OSD_LOG
81   osd_logprint (string);
82 #endif /* OSD_LOG */
83   /* Log it to disk, as well */
84   fputs (string, errorlog);
85 #endif /* NOFRENDO_DEBUG */
86 }
87
88 void
89 log_printf (const char *format, ...)
90 {
91 #ifdef NOFRENDO_DEBUG
92 #ifdef OSD_LOG
93   char buffer[1024 + 1];
94 #endif /* OSD_LOG */
95   va_list arg;
96
97   va_start (arg, format);
98
99 #ifdef OSD_LOG
100   vsprintf (buffer, format, arg);
101   osd_logprint (buffer);
102 #endif /* OSD_LOG */
103   vfprintf (errorlog, format, arg);
104   va_end (arg);
105 #endif /* NOFRENDO_DEBUG */
106 }
107
108 /*
109 ** $Log$
110 ** Revision 1.2  2008/03/25 15:56:11  slomo
111 ** Patch by: Andreas Henriksson <andreas at fatal dot set>
112 ** * gst/nsf/Makefile.am:
113 ** * gst/nsf/dis6502.h:
114 ** * gst/nsf/fds_snd.c:
115 ** * gst/nsf/fds_snd.h:
116 ** * gst/nsf/fmopl.c:
117 ** * gst/nsf/fmopl.h:
118 ** * gst/nsf/gstnsf.c:
119 ** * gst/nsf/log.c:
120 ** * gst/nsf/log.h:
121 ** * gst/nsf/memguard.c:
122 ** * gst/nsf/memguard.h:
123 ** * gst/nsf/mmc5_snd.c:
124 ** * gst/nsf/mmc5_snd.h:
125 ** * gst/nsf/nes6502.c:
126 ** * gst/nsf/nes6502.h:
127 ** * gst/nsf/nes_apu.c:
128 ** * gst/nsf/nes_apu.h:
129 ** * gst/nsf/nsf.c:
130 ** * gst/nsf/nsf.h:
131 ** * gst/nsf/osd.h:
132 ** * gst/nsf/types.h:
133 ** * gst/nsf/vrc7_snd.c:
134 ** * gst/nsf/vrc7_snd.h:
135 ** * gst/nsf/vrcvisnd.c:
136 ** * gst/nsf/vrcvisnd.h:
137 ** Update our internal nosefart to nosefart-2.7-mls to fix segfaults
138 ** on some files. Fixes bug #498237.
139 ** Remove some // comments, fix some compiler warnings and use pow()
140 ** instead of a slow, selfmade implementation.
141 **
142 ** Revision 1.1  2003/04/08 20:46:46  ben
143 ** add new input for NES music file.
144 **
145 ** Revision 1.5  2000/06/26 04:55:33  matt
146 ** minor change
147 **
148 ** Revision 1.4  2000/06/09 15:12:25  matt
149 ** initial revision
150 **
151 */