01: /**
02: * Copyright 2003 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */package com.sun.portal.wsrp.producer;
13:
14: import com.sun.portal.log.common.PortalLogger;
15:
16: import java.util.logging.Level;
17: import java.util.logging.Logger;
18:
19: public class PortTypeLogger {
20: private static Logger logger = PortalLogger
21: .getLogger(PortTypeLogger.class);
22:
23: public static void error(Producer p, String msg) {
24: error(p, msg, null);
25: }
26:
27: public static void warning(Producer p, String msg) {
28: if (logger.isLoggable(Level.WARNING)) {
29: StringBuffer b = getBuffer(p, msg, null);
30: logger.log(Level.WARNING, b.toString());
31: }
32: }
33:
34: public static void message(Producer p, String msg) {
35: if (logger.isLoggable(Level.FINEST)) {
36: StringBuffer b = getBuffer(p, msg, null);
37: logger.log(Level.FINEST, b.toString());
38: }
39: }
40:
41: public static void error(Producer p, Throwable t) {
42: error(p, null, t);
43: }
44:
45: public static void error(Producer p, String msg, Throwable t) {
46:
47: if (logger.isLoggable(Level.SEVERE)) {
48: StringBuffer b = getBuffer(p, msg, t);
49: if (t != null)
50: logger.log(Level.SEVERE, b.toString(), t);
51: else
52: logger.log(Level.SEVERE, b.toString());
53: }
54: }
55:
56: public static void perf(Producer p, String msg) {
57: }
58:
59: private static StringBuffer getBuffer(Producer p, String msg,
60: Throwable t) {
61: String producerKey = null;
62: if (p != null) {
63: producerKey = p.getProducerKey();
64: } else {
65: producerKey = "<unknown>";
66: }
67:
68: StringBuffer b = new StringBuffer();
69: b.append("[ producerKey=").append(producerKey).append(" ] ");
70: if (msg == null && t != null) {
71: msg = t.getMessage();
72: }
73: if (msg != null) {
74: b.append(msg);
75: }
76:
77: return b;
78: }
79:
80: }
|