KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > LogStreamHandler


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */

18
19 package org.apache.tools.ant.taskdefs;
20
21 import java.io.IOException JavaDoc;
22 import org.apache.tools.ant.BuildException;
23 import org.apache.tools.ant.ProjectComponent;
24 import org.apache.tools.ant.Task;
25
26 /**
27  * Logs standard output and error of a subprocess to the log system of ant.
28  *
29  * @since Ant 1.2
30  */

31 public class LogStreamHandler extends PumpStreamHandler {
32
33     /**
34      * Creates log stream handler
35      *
36      * @param task the task for whom to log
37      * @param outlevel the loglevel used to log standard output
38      * @param errlevel the loglevel used to log standard error
39      */

40     public LogStreamHandler(Task task, int outlevel, int errlevel) {
41         this((ProjectComponent) task, outlevel, errlevel);
42     }
43
44     /**
45      * Creates log stream handler
46      *
47      * @param pc the project component for whom to log
48      * @param outlevel the loglevel used to log standard output
49      * @param errlevel the loglevel used to log standard error
50      */

51     public LogStreamHandler(ProjectComponent pc, int outlevel, int errlevel) {
52         super(new LogOutputStream(pc, outlevel),
53               new LogOutputStream(pc, errlevel));
54     }
55
56     /**
57      * Stop the log stream handler.
58      */

59     public void stop() {
60         super.stop();
61         try {
62             getErr().close();
63             getOut().close();
64         } catch (IOException JavaDoc e) {
65             // plain impossible
66
throw new BuildException(e);
67         }
68     }
69 }
70
Popular Tags