01: /*
02: * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05: package com.sun.portal.monitoring;
06:
07: import com.sun.portal.log.common.PortalLogger;
08:
09: import java.util.logging.Logger;
10: import java.util.logging.Level;
11: import java.util.logging.LogRecord;
12: import java.io.StringWriter;
13: import java.io.PrintWriter;
14:
15: public class Debug {
16: private static Logger logger = PortalLogger.getLogger(Debug.class);
17:
18: public static Logger getLogger() {
19: return logger;
20: }
21:
22: public static String getStackTrace(Throwable t) {
23: StringWriter sw = new StringWriter();
24: PrintWriter pw = new PrintWriter(sw);
25: t.printStackTrace(pw);
26: return sw.getBuffer().toString();
27: }
28:
29: private static LogRecord getLogRecord(Level level, String message,
30: Object[] parameters, Throwable t) {
31: LogRecord result = new LogRecord(level, message);
32: result.setParameters(parameters);
33: result.setThrown(t);
34: return result;
35: }
36:
37: public static void severe(String message, Object[] parameters,
38: Throwable t) {
39: logger.log(getLogRecord(Level.SEVERE, message, parameters, t));
40: }
41:
42: public static void warning(String message, Object[] parameters,
43: Throwable t) {
44: logger.log(getLogRecord(Level.WARNING, message, parameters, t));
45: }
46:
47: public static void info(String message, Object[] parameters,
48: Throwable t) {
49: logger.log(getLogRecord(Level.INFO, message, parameters, t));
50: }
51:
52: public static void config(String message, Object[] parameters,
53: Throwable t) {
54: logger.log(getLogRecord(Level.CONFIG, message, parameters, t));
55: }
56:
57: public static void fine(String message, Object[] parameters,
58: Throwable t) {
59: logger.log(getLogRecord(Level.FINE, message, parameters, t));
60: }
61:
62: public static void finer(String message, Object[] parameters,
63: Throwable t) {
64: logger.log(getLogRecord(Level.FINER, message, parameters, t));
65: }
66:
67: public static void finest(String message, Object[] parameters,
68: Throwable t) {
69: logger.log(getLogRecord(Level.FINEST, message, parameters, t));
70: }
71: }
|