View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.common.util.log;
17  
18  import org.codehaus.plexus.util.cli.StreamConsumer;
19  import org.kuali.common.util.Assert;
20  import org.slf4j.Logger;
21  
22  /**
23   * @deprecated
24   */
25  @Deprecated
26  public final class LoggingStreamConsumer implements StreamConsumer {
27  
28  	private final Logger logger;
29  	private final LoggerLevel level;
30  
31  	public LoggingStreamConsumer(Logger logger) {
32  		this(logger, LoggerLevel.INFO);
33  	}
34  
35  	public LoggingStreamConsumer(Logger logger, LoggerLevel level) {
36  		Assert.noNulls(logger, level);
37  		this.logger = logger;
38  		this.level = level;
39  	}
40  
41  	@Override
42  	public void consumeLine(String line) {
43  		switch (level) {
44  		case TRACE:
45  			logger.trace(line);
46  			return;
47  		case DEBUG:
48  			logger.debug(line);
49  			return;
50  		case INFO:
51  			logger.info(line);
52  			return;
53  		case WARN:
54  			logger.warn(line);
55  			return;
56  		case ERROR:
57  			logger.error(line);
58  			return;
59  		default:
60  			throw new IllegalStateException("Logger level " + level + " is unknown");
61  		}
62  	}
63  
64  	public Logger getLogger() {
65  		return logger;
66  	}
67  
68  	public LoggerLevel getLevel() {
69  		return level;
70  	}
71  
72  }