001/**
002 * Copyright 2010-2014 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.common.util;
017
018import org.codehaus.plexus.util.cli.StreamConsumer;
019import org.slf4j.Logger;
020
021/**
022 * @deprecated
023 */
024@Deprecated
025public class LoggingStreamConsumer implements StreamConsumer {
026
027        Logger logger;
028        LoggerLevel level;
029
030        public LoggingStreamConsumer() {
031                this(null);
032        }
033
034        public LoggingStreamConsumer(Logger logger) {
035                this(logger, LoggerLevel.INFO);
036        }
037
038        public LoggingStreamConsumer(Logger logger, LoggerLevel level) {
039                super();
040                this.logger = logger;
041                this.level = level;
042        }
043
044        @Override
045        public void consumeLine(String line) {
046                switch (level) {
047                case TRACE:
048                        logger.trace(line);
049                        return;
050                case DEBUG:
051                        logger.debug(line);
052                        return;
053                case INFO:
054                        logger.info(line);
055                        return;
056                case WARN:
057                        logger.warn(line);
058                        return;
059                case ERROR:
060                        logger.error(line);
061                        return;
062                default:
063                        throw new IllegalStateException("Logger level " + level + " is unknown");
064                }
065        }
066
067        public Logger getLogger() {
068                return logger;
069        }
070
071        public void setLogger(Logger logger) {
072                this.logger = logger;
073        }
074
075        public LoggerLevel getLevel() {
076                return level;
077        }
078
079        public void setLevel(LoggerLevel level) {
080                this.level = level;
081        }
082
083}