~ubuntu-branches/ubuntu/precise/kompozer/precise

« back to all changes in this revision

Viewing changes to mozilla/extensions/xmlterm/lineterm/tracelog.h

  • Committer: Bazaar Package Importer
  • Author(s): Anthony Yarusso
  • Date: 2007-08-27 01:11:03 UTC
  • Revision ID: james.westby@ubuntu.com-20070827011103-2jgf4s6532gqu2ka
Tags: upstream-0.7.10
ImportĀ upstreamĀ versionĀ 0.7.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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/
 
6
 * 
 
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.
 
11
 * 
 
12
 * The Original Code is lineterm.
 
13
 * 
 
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.
 
17
 * 
 
18
 * Contributor(s):
 
19
 * 
 
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
 
30
 * GPL.
 
31
 */
 
32
 
 
33
/* tracelog.h: Tracing/logging module header
 
34
 * CPP options:
 
35
 *   DEBUG_LTERM:          to enable debugging output
 
36
 *   _UNISTRING_H:   for unicode messages compatible with "unistring.h"
 
37
 */
 
38
 
 
39
#ifndef _TRACELOG_H
 
40
 
 
41
#define _TRACELOG_H 1
 
42
 
 
43
#include <stdio.h>
 
44
#include <string.h>
 
45
 
 
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));
 
56
 */
 
57
 
 
58
/* Max. number of modules recognized by TRACELOG */
 
59
# define TLOG_MAXMODULES 50
 
60
 
 
61
#ifdef  __cplusplus
 
62
extern "C" {
 
63
#endif
 
64
 
 
65
/* Initializes all TRACELOG operations;
 
66
 * needs to be called before any other trace/log calls.
 
67
 *
 
68
 * FILESTREAM is the file stream to be used to print messages.
 
69
 *
 
70
 * Normally, only error messages are sent to FILESTREAM.
 
71
 * If FILESTREAM is null, all output, including error output, is suppressed.
 
72
 */
 
73
 
 
74
void tlog_init(FILE* fileStream);
 
75
 
 
76
/** Set diagnostic message display level for module no. IMODULE.
 
77
 * (0 <= IMODULE < TLOG_MAXMODULES)
 
78
 *
 
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;
 
83
 *                ...
 
84
 *                level 50, 51, ...: innermost level)
 
85
 *
 
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
 
89
 * are displayed
 
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.
 
93
 *
 
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.
 
99
 *
 
100
 * FUNCTIONLIST is a colon-separated string of function names, e.g.,
 
101
 * "func_a:func_b".
 
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
 
107
 * to be wild-carded.
 
108
 *
 
109
 * Returns 0 on success, -1 otherwise (i.e., for invalid module numbers)
 
110
 */
 
111
 
 
112
int tlog_set_level(int imodule, int messageLevel, const char *functionList);
 
113
 
 
114
int tlog_test(int imodule, char *procname, int level);
 
115
void tlog_message(const char *format, ...);
 
116
void tlog_warning(const char *format, ...);
 
117
 
 
118
/* TRACELOG global variables */
 
119
typedef struct { 
 
120
  FILE *errorStream;                     /* file stream for logging */
 
121
  int debugOn;
 
122
  int messageLevel[TLOG_MAXMODULES];
 
123
  char *functionList[TLOG_MAXMODULES];   /* list of functions to be debugged */
 
124
} TlogGlobal;
 
125
 
 
126
extern TlogGlobal tlogGlobal;
 
127
 
 
128
#ifdef  __cplusplus
 
129
}
 
130
#endif
 
131
 
 
132
#if defined(USE_NSPR_BASE) && !defined(DEBUG_LTERM)
 
133
#include "prlog.h"
 
134
#define TLOG_MESSAGE PR_LogPrint
 
135
#else
 
136
#define TLOG_MESSAGE tlog_message
 
137
#endif
 
138
 
 
139
#define TLOG_ERROR TLOG_MESSAGE
 
140
 
 
141
#define TLOG_WARNING if (tlogGlobal.debugOn) TLOG_MESSAGE
 
142
 
 
143
#define TLOG_PRINT(imodule,procname,level,args) \
 
144
do {                                            \
 
145
  if (tlogGlobal.debugOn && tlog_test(imodule,":" #procname ":",level)) {  \
 
146
      TLOG_MESSAGE args;                                                  \
 
147
  }                                             \
 
148
} while(0)
 
149
 
 
150
#ifdef _UNISTRING_H
 
151
void tlog_unichar(const UNICHAR *buf, int count);
 
152
 
 
153
#define TLOG_UNICHAR(imodule,procname,level,args) \
 
154
do {                                              \
 
155
if (tlogGlobal.debugOn && tlog_test(imodule,":" #procname ":",level)) {  \
 
156
    tlog_unichar args;                            \
 
157
  }                                               \
 
158
} while(0)
 
159
#endif
 
160
 
 
161
#endif  /* _TRACELOG_H */