1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19

20
/**
21
 * Extends the Writer class to output messages to Phing's log
22
 *
23
 * @author  Michiel Rook <mrook@php.net>
24
 * @package phing.util
25
 */
26
class LogWriter extends Writer
27
{
28
    private $task = null;
29

30
    private $level = null;
31

32
    /**
33
     * Constructs a new LogWriter object
34
     *
35
     * @param Task $task
36
     * @param int $level
37
     */
38 1
    public function __construct(Task $task, $level = Project::MSG_INFO)
39
    {
40 1
        $this->task = $task;
41 1
        $this->level = $level;
42
    }
43

44
    /**
45
     * @see Writer::write()
46
     * @param string $buf
47
     * @param null $off
48
     * @param null $len
49
     */
50 1
    public function write($buf, $off = null, $len = null)
51
    {
52 1
        $lines = explode("\n", $buf);
53

54 1
        foreach ($lines as $line) {
55 1
            if ($line == "") {
56 1
                continue;
57
            }
58

59 1
            $this->task->log($line, $this->level);
60
        }
61
    }
62

63
    /**
64
     * @see Writer::reset()
65
     */
66 0
    public function reset()
67
    {
68
    }
69

70
    /**
71
     * @see Writer::close()
72
     */
73 1
    public function close()
74
    {
75
    }
76

77
    /**
78
     * @see Writer::open()
79
     */
80 0
    public function open()
81
    {
82
    }
83

84
    /**
85
     * @see Writer::getResource()
86
     */
87 0
    public function getResource()
88
    {
89 0
        return $this->task;
90
    }
91
}

Read our documentation on viewing source code .

Loading