| 1 | /* |
| 2 | * Copyright 2005-2006 The RbUtils Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | * |
| 16 | */ |
| 17 | |
| 18 | // $Id: DefaultLogger.java,v 1.5 2007/07/08 03:55:24 moishi Exp $ |
| 19 | |
| 20 | package org.ktc.rbutils.rb.check; |
| 21 | |
| 22 | import java.io.OutputStream; |
| 23 | import org.ktc.rbutils.api.audit.AbstractDefaultLogger; |
| 24 | import org.ktc.rbutils.api.audit.event.ProcessEvent; |
| 25 | |
| 26 | /** |
| 27 | * Plain text logger for RbChecker. |
| 28 | * @see org.ktc.rbutils.audit.DefaultLogger |
| 29 | * @since RbUtils 0.4 |
| 30 | * @version $Revision: 1.5 $ |
| 31 | * @author redfish |
| 32 | */ |
| 33 | public class DefaultLogger extends AbstractDefaultLogger { |
| 34 | |
| 35 | /** |
| 36 | * Creates a new <code>DefaultLogger</code> instance. |
| 37 | * @param infoStream the <code>OutputStream</code> for info messages |
| 38 | * @param closeInfoAfterUse auditFinished should close aInfoStream |
| 39 | * @param errorStream the <code>OutputStream</code> for error messages |
| 40 | * @param closeErrorAfterUse auditFinished should close aErrorStream |
| 41 | */ |
| 42 | public DefaultLogger(final OutputStream infoStream, final boolean closeInfoAfterUse, |
| 43 | final OutputStream errorStream, final boolean closeErrorAfterUse) |
| 44 | { |
| 45 | super(infoStream, closeInfoAfterUse, errorStream, closeErrorAfterUse); |
| 46 | // RBUTILS-027 |
| 47 | // TODO we have a duplication here because we do not use CommonProperties |
| 48 | // which is suppose to manage the name of the task and the rbutils version |
| 49 | this.taskname = "RbChecker"; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * {@inheritDoc} |
| 54 | */ |
| 55 | public void addError(final ProcessEvent event) { |
| 56 | final String message = event.getMessageDisplay(); |
| 57 | final String errorType = event.getDetailledMessage(); |
| 58 | final String msgType = event.getMessageTypeDisplay(); |
| 59 | |
| 60 | final StringBuffer sb = new StringBuffer(100); |
| 61 | sb.append(msgType + " - " + errorType); |
| 62 | sb.append(": ").append(message); |
| 63 | |
| 64 | errorWriter.println(getMsgWithFilePathPrefix(sb.toString())); |
| 65 | } |
| 66 | |
| 67 | } |