001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: *
013: * @created Jul 28, 2005
014: * @author James Dixon
015: */
016:
017: package org.pentaho.core.system;
018:
019: import java.util.List;
020:
021: import org.pentaho.messages.Messages;
022:
023: public abstract class PentahoMessenger extends PentahoBase {
024:
025: private List messages;
026:
027: public List getMessages() {
028: return messages;
029: }
030:
031: public void setMessages(List messages) {
032: this .messages = messages;
033: }
034:
035: public void trace(String message) {
036: if (loggingLevel <= TRACE) {
037: if (messages != null) {
038: messages
039: .add(Messages
040: .getString(
041: "Message.USER_DEBUG", message, getClass().getName())); //$NON-NLS-1$
042: }
043: super .trace(message);
044: }
045: }
046:
047: public void debug(String message) {
048: if (loggingLevel <= DEBUG) {
049: if (messages != null) {
050: messages
051: .add(Messages
052: .getString(
053: "Message.USER_DEBUG", message, getClass().getName())); //$NON-NLS-1$
054: }
055: super .debug(message);
056: }
057: }
058:
059: public void info(String message) {
060: if (loggingLevel <= INFO) {
061: if (messages != null) {
062: messages
063: .add(Messages
064: .getString(
065: "Message.USER_INFO", message, getClass().getName())); //$NON-NLS-1$
066: }
067: super .info(message);
068: }
069: }
070:
071: public void warn(String message) {
072: if (loggingLevel <= WARN) {
073: if (messages != null) {
074: messages
075: .add(Messages
076: .getString(
077: "Message.USER_WARNING", message, getClass().getName())); //$NON-NLS-1$
078: }
079: super .warn(message);
080: }
081: }
082:
083: public void error(String message) {
084: if (loggingLevel <= ERROR) {
085: if (messages != null) {
086: messages
087: .add(Messages
088: .getString(
089: "Message.USER_ERROR", message, getClass().getName())); //$NON-NLS-1$
090: }
091: super .error(message);
092: }
093: }
094:
095: public void fatal(String message) {
096: if (loggingLevel <= FATAL) {
097: if (messages != null) {
098: messages
099: .add(Messages
100: .getString(
101: "Message.USER_ERROR", message, getClass().getName())); //$NON-NLS-1$
102: }
103: super .fatal(message);
104: }
105: }
106:
107: public void trace(String message, Throwable error) {
108: if (loggingLevel <= TRACE) {
109: if (messages != null) {
110: messages
111: .add(Messages
112: .getString(
113: "Message.USER_DEBUG", message, getClass().getName())); //$NON-NLS-1$
114: }
115: super .trace(message, error);
116: }
117: }
118:
119: public void debug(String message, Throwable error) {
120: if (loggingLevel <= DEBUG) {
121: if (messages != null) {
122: messages
123: .add(Messages
124: .getString(
125: "Message.USER_DEBUG", message, getClass().getName())); //$NON-NLS-1$
126: }
127: super .debug(message, error);
128: }
129: }
130:
131: public void info(String message, Throwable error) {
132: if (loggingLevel <= INFO) {
133: if (messages != null) {
134: messages
135: .add(Messages
136: .getString(
137: "Message.USER_INFO", message, getClass().getName())); //$NON-NLS-1$
138: }
139: super .info(message, error);
140: }
141: }
142:
143: public void warn(String message, Throwable error) {
144: if (loggingLevel <= WARN) {
145: if (messages != null) {
146: messages
147: .add(Messages
148: .getString(
149: "Message.USER_WARNING", message, getClass().getName())); //$NON-NLS-1$
150: }
151: super .warn(message, error);
152: }
153: }
154:
155: public void error(String message, Throwable error) {
156: if (loggingLevel <= ERROR) {
157: if (messages != null) {
158: messages
159: .add(Messages
160: .getString(
161: "Message.USER_ERROR_EX", message, getClass().getName(), error.toString())); //$NON-NLS-1$
162: }
163: super .error(message, error);
164: }
165: }
166:
167: public void fatal(String message, Throwable error) {
168: if (loggingLevel <= FATAL) {
169: if (messages != null) {
170: messages
171: .add(Messages
172: .getString(
173: "Message.USER_ERROR_EX", message, getClass().getName(), error.toString())); //$NON-NLS-1$
174: }
175: super .fatal(message, error);
176: }
177: }
178:
179: public static String getUserString(String type) {
180: return Messages.getString("Message.USER_" + type); //$NON-NLS-1$
181: }
182:
183: }
|