dftk
[ class tree: dftk ] [ index: dftk ] [ all elements ]

Source for file dftk_output_logfile.php

Documentation is available at dftk_output_logfile.php


1 <?php
2 /*
3
4 Copyright (c)2003 DuckCorp(tm) and RtpNet(tm)
5
6
7
8 This file is part of DFTK.
9
10 DFTK is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
14
15 DFTK is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with DFTK; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24
25
26 /**
27 * @package dftk
28 * @author Duck <duck@DuckCorp.org>
29 * @author Rtp <rtp@rtp-net.org>
30 * @copyright Copyright (c)2003 DuckCorp(tm) and RtpNet(tm)
31 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
32 * @version 0.4.0
33 */
34
35
36 /**
37 * DFTK Stdout Output Class
38 *
39 * @package dftk
40 * @subpackage dftk-output
41 * @author Duck <duck@DuckCorp.org>
42 *
43 * @access public
44 */
45 class DftkOutputLogfile extends DftkOutput
46 {
47 /**
48 * Filename for log
49 *
50 * @access private
51 * @var string
52 */
53 var $_filename;
54
55 /**
56 * Constructor
57 *
58 * @access public
59 * @param object DftkDaTraceManager &$tracemgr Language Manager
60 * @param string $filename Log file name
61 */
62 function DftkOutputLogfile(&$tracemgr, $filename)
63 {
64 DftkOutput::DftkOutput(&$tracemgr);
65
66 $this->_filename = $filename;
67
68 register_shutdown_function(array(&$this, "_DftkOutputLogfile"));
69 }
70
71 /**
72 * Destructor
73 *
74 * @access private
75 */
76 function _DftkOutputLogfile()
77 {
78 }
79
80 /**
81 * Flush output
82 *
83 * @access public
84 * @return object DftkDaTrace $r Trace
85 */
86 function &flush_output()
87 {
88 $r =& $this->_tracemgr->create_trace();
89
90 $fp = fopen($this->_filename, "a");
91 if (!$fp)
92 $r->add_event('dftk-output_ioerr');
93
94 if (!$r->has_error())
95 {
96 if (!fwrite($fp, $this->_header.$this->_content.$this->_footer))
97 $r->add_event('dftk-output_ioerr');
98
99 if (!$r->has_error())
100 {
101 if (!fclose($fp))
102 $r->add_event('dftk-output_ioerr');
103 }
104 }
105
106 $r2 =& DftkOutput::flush_output();
107 $r->merge_traces($r2);
108
109 return $r;
110 }
111
112 /**
113 * Clear log
114 *
115 * @access public
116 * @return object DftkDaTrace $r Trace
117 */
118 function &clear_log()
119 {
120 $r =& $this->_tracemgr->create_trace();
121
122 if (file_exists($this->_filename))
123 {
124 if (!unlink($this->_filename))
125 $r->add_event('dftk-output_ioerr');
126 }
127
128 return $r;
129 }
130 }
131
132 ?>

Documentation generated on Sat, 6 Dec 2003 13:47:42 +0100 by phpDocumentor 1.2.3