2
* The contents of this file are subject to the Mozilla Public
3
* License Version 1.1 (the "MPL"); you may not use this file
4
* except in compliance with the MPL. You may obtain a copy of
5
* the MPL at http://www.mozilla.org/MPL/
7
* Software distributed under the MPL is distributed on an "AS
8
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
9
* implied. See the MPL for the specific language governing
10
* rights and limitations under the MPL.
12
* The Original Code is lineterm.
14
* The Initial Developer of the Original Code is Ramalingam Saravanan.
15
* Portions created by Ramalingam Saravanan <svn@xmlterm.org> are
16
* Copyright (C) 1999 Ramalingam Saravanan. All Rights Reserved.
20
* Alternatively, the contents of this file may be used under the
21
* terms of the GNU General Public License (the "GPL"), in which case
22
* the provisions of the GPL are applicable instead of
23
* those above. If you wish to allow use of your version of this
24
* file only under the terms of the GPL and not to allow
25
* others to use your version of this file under the MPL, indicate
26
* your decision by deleting the provisions above and replace them
27
* with the notice and other provisions required by the GPL.
28
* If you do not delete the provisions above, a recipient
29
* may use your version of this file under either the MPL or the
33
/* tracelog.h: Tracing/logging module header
35
* DEBUG_LTERM: to enable debugging output
36
* _UNISTRING_H: for unicode messages compatible with "unistring.h"
46
/* Trace/log macros (to be used after call to tlog_init to initialize):
47
* TLOG_ERROR: error message macro, e.g.,
48
* TLOG_ERROR(format, val1, val2);
49
* TOG_WARNING: warning message macro, e.g.,
50
* TLOG_WARNING(format, val1, val2);
51
* TLOG_PRINT: message logging macro, e.g., (no terminating semicolon)
52
* TLOG_PRINT(10,(format, val1, val2));
53
* (if UNISTRING module is being used)
54
* TLOG_UNICHAR: Unicode string logging macro, e.g., (no terminating semicolon)
55
* TLOG_UNICHAR(10,(label,str,count));
58
/* Max. number of modules recognized by TRACELOG */
59
# define TLOG_MAXMODULES 50
65
/* Initializes all TRACELOG operations;
66
* needs to be called before any other trace/log calls.
68
* FILESTREAM is the file stream to be used to print messages.
70
* Normally, only error messages are sent to FILESTREAM.
71
* If FILESTREAM is null, all output, including error output, is suppressed.
74
void tlog_init(FILE* fileStream);
76
/** Set diagnostic message display level for module no. IMODULE.
77
* (0 <= IMODULE < TLOG_MAXMODULES)
79
* MESSAGELEVEL (>=0) specifies the diagnostic message display level:
80
* only diagnostic messages with level values >= MESSAGELEVEL are printed
81
* (For example, level 10, 11, ...: outermost level;
82
* level 20, 21, ...: next inner level;
84
* level 50, 51, ...: innermost level)
86
* The message SUBLEVEL threshold is defined as MESSAGELEVEL%10
87
* (ranging from 0 to 9).
88
* Only those diagnostic messages with sublevel values >= SUBLEVEL threshold
90
* Usually, the SUBLEVEL threshold values are interpreted as
91
* 0 => print single message per selected procedure.
92
* 1...9 => print only messages upto selected sublevel.
94
* Setting MESSAGELEVEL to zero and FUNCTIONLIST to null for all modules
95
* disables debugging and printing of warning messages.
96
* (This is the initial configuration following the call to lterm_init.)
97
* Setting MESSAGELEVEL to 1 for atleast one module enables debugging and
98
* causes warning messages for all modules to be printed.
100
* FUNCTIONLIST is a colon-separated string of function names, e.g.,
102
* Trace/log messages for functions in this list are always output
103
* if debugging is enabled provided the sublevel values exceed the threshold,
104
* regardless of full message level values.
105
* If FUNCTIONLIST contains a single method name without a class name, or a
106
* class name without a method name, then the missing portion is assumed
109
* Returns 0 on success, -1 otherwise (i.e., for invalid module numbers)
112
int tlog_set_level(int imodule, int messageLevel, const char *functionList);
114
int tlog_test(int imodule, char *procname, int level);
115
void tlog_message(const char *format, ...);
116
void tlog_warning(const char *format, ...);
118
/* TRACELOG global variables */
120
FILE *errorStream; /* file stream for logging */
122
int messageLevel[TLOG_MAXMODULES];
123
char *functionList[TLOG_MAXMODULES]; /* list of functions to be debugged */
126
extern TlogGlobal tlogGlobal;
132
#if defined(USE_NSPR_BASE) && !defined(DEBUG_LTERM)
134
#define TLOG_MESSAGE PR_LogPrint
136
#define TLOG_MESSAGE tlog_message
139
#define TLOG_ERROR TLOG_MESSAGE
141
#define TLOG_WARNING if (tlogGlobal.debugOn) TLOG_MESSAGE
143
#define TLOG_PRINT(imodule,procname,level,args) \
145
if (tlogGlobal.debugOn && tlog_test(imodule,":" #procname ":",level)) { \
151
void tlog_unichar(const UNICHAR *buf, int count);
153
#define TLOG_UNICHAR(imodule,procname,level,args) \
155
if (tlogGlobal.debugOn && tlog_test(imodule,":" #procname ":",level)) { \
161
#endif /* _TRACELOG_H */