Project

General

Profile

« Previous | Next » 

Revision 2512

Added by sgarg about 19 years ago

Added a new function which can used to control the carriage return at the end of the debug message and 'Metacat' in front of the message...

View differences:

src/edu/ucsb/nceas/metacat/MetaCatUtil.java
218 218
        }
219 219
    }
220 220

  
221

  
222
    /**
223
     * Utility method to print debugging messages. User can set debug level for
224
     * this message. The number is fewer, the message is more important. Can be
225
     * used to control if the carriage return and debugPrefix are printed
226
     *
227
     * @param msg, the content of the message
228
     * @param debugLevel, an integer indicating the message debug level
229
     * @param debugPrefix, a boolean indicating whether debugprefix
230
     *                    should be printed or not
231
     */
232
    public static void debugMessageDetail(String msg, int debugLevel,
233
                                      boolean carriageReturn,
234
                                      boolean debugPrefix)
235
    {
236
        if (debug) {
237
            int limit = 1;
238
            try {
239
                limit = Integer.parseInt(getOption("debuglevel"));
240

  
241
            } catch (Exception e) {
242
                System.out.println(e.getMessage());
243
            }
244
            //don't allow the user set debugLevel less than or equals 0
245
            if (debugLevel <= 0) {
246
                debugLevel = 1;
247
            }
248

  
249
            if (debugLevel < limit) {
250
                if(debugPrefix) {
251
                    if(carriageReturn)
252
                        System.err.println("@debugprefix@ " + msg);
253
                    else
254
                        System.err.print("@debugprefix@ " + msg);
255
                } else {
256
                    if(carriageReturn)
257
                        System.err.println(msg);
258
                    else
259
                        System.err.print(msg);
260
                }
261
            }
262
        }
263
    }
264

  
265

  
221 266
    public static Vector getOptionList(String optiontext)
222 267
    {
223 268
        Vector optionsVector = new Vector();

Also available in: Unified diff