Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezpblog.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: eZPBLog.php 6304 2001-07-29 23:31:17Z kaid $
5 //
6 // Definition of eZPBLog class
7 //
8 // Created on: <15-Oct-2000 13:28:44 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
75 class eZPBLog
76 {
82 function __construct( $fileName="" )
83 {
84 if ( file_exists( $fileName ) )
85 {
86 $this->LogFile = eZPBFile::fopen( $fileName, "a" );
87 }
88 else
89 {
90 //include_once( "kernel/classes/INIFile.php" );
91 $ini =& eZINI::instance( 'site.ini' );
92
93 $fileName = $ini->variable( "site", "LogFileName" );
94 $logDir = $ini->variable( "site", "LogDir" );
95
96 // build timestamp for today's date
97 //include_once( "kernel/classes/ezdate.php" );
98
99 $today = new eZDate();
100 $year = eZDateTime::addZero( $today->year() );
101 $month = eZDateTime::addZero( $today->month() );
102 $day = eZDateTime::addZero( $today->day() );
103
104 // append timestamp to log file name
105 $timestamp = $year ."_". $month ."_". $day;
106 $fileName = $logDir . $fileName ."_". $timestamp .".log";
107
108 if ( file_exists( $fileName ) )
109 {
110 $this->LogFile = eZPBFile::fopen( $fileName, "a" );
111 }
112 else
113 {
114 $this->LogFile = eZPBFile::fopen( $fileName, "a+" );
115 }
116
117 if ( !$this->LogFile )
118 {
119 print( "Log file ( $fileName ) could not be opened." );
120 }
121 }
122 }
123
127 function close()
128 {
129 fclose( $this->LogFile );
130 }
131
135 function notice( $notice )
136 {
137 $time = date("%b %d %Y %H:%M:%S", strtotime( "now" ) );
138 $notice = "[ " . $time . " ] [notice] " . $notice . "\n";
139 fwrite( $this->LogFile, $notice );
140 }
141
145 function warning( $warning )
146 {
147 $time = date("%b %d %Y %H:%M:%S", strtotime( "now" ) );
148 $warning = "[ " . $time . " ] [warning] " . $warning . "\n";
149 fwrite( $this->LogFile, $warning );
150 }
151
155 function error( $error )
156 {
157 $time = date("%b %d %Y %H:%M:%S", strtotime( "now" ) );
158 $error = "[ " . $time . " ] [error] " . $error . "\n";
159 fwrite( $this->LogFile, $error );
160 }
161
166 static public function writeNotice( $notice )
167 {
168 $log = new eZPBLog();
169 $log->notice( $notice );
170 $log->close();
171 }
172
177 static public function writeWarning( $warning )
178 {
179 $log = new eZPBLog();
180 $log->warning( $warning );
181 $log->close();
182 }
183
188 function writeError( $error )
189 {
190 $log = new eZPBLog();
191 $log->error( $error );
192 $log->close();
193 }
194
202 public static function write( $message, $type="" )
203 {
204 switch ( $type )
205 {
206 case "warning" :
207 {
208 $log = new eZPBLog();
209 $log->warning( $message );
210 $log->close();
211 }
212 break;
213
214 case "error" :
215 {
216 $log = new eZPBLog();
217 $log->error( $message );
218 $log->close();
219 }
220 break;
221
222 case "notice" :
223 {
224 $log = new eZPBLog();
225 $log->notice( $message );
226 $log->close();
227 }
228 break;
229
230 default :
231 {
232 $log = new eZPBLog();
233 $log->notice( $message );
234 $log->close();
235 }
236 break;
237 }
238 }
239
240 var $LogFile;
241 }
242
243 ?>
$message
$message
Definition: admin/message.php:51
$day
else $day
Definition: appointmentedit.php:665
$year
else $year
Definition: appointmentedit.php:655
$today
$today
Definition: appointmentedit.php:651
$month
else $month
Definition: appointmentedit.php:660
eZDateTime\addZero
static addZero( $value)
Definition: ezdatetime.php:363
eZDate
Definition: ezdate.php:46
eZPBFile\fopen
static fopen( $filename, $options)
Definition: ezpbfile.php:326
eZPBLog
Definition: ezpblog.php:76
eZPBLog\warning
warning( $warning)
Definition: ezpblog.php:145
eZPBLog\notice
notice( $notice)
Definition: ezpblog.php:135
eZPBLog\writeNotice
static writeNotice( $notice)
Definition: ezpblog.php:166
eZPBLog\__construct
__construct( $fileName="")
Definition: ezpblog.php:82
eZPBLog\close
close()
Definition: ezpblog.php:127
eZPBLog\write
static write( $message, $type="")
Definition: ezpblog.php:202
eZPBLog\error
error( $error)
Definition: ezpblog.php:155
eZPBLog\$LogFile
$LogFile
Definition: ezpblog.php:240
eZPBLog\writeError
writeError( $error)
Definition: ezpblog.php:188
eZPBLog\writeWarning
static writeWarning( $warning)
Definition: ezpblog.php:177
$ini
$ini
Definition: classes/admin/linklist.php:64
$type
$type
Definition: classes/admin/linkselect.php:220
file_exists
static file_exists( $inifilename)
Definition: eZPBINIFile.php:195
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
$fileName
if(eZObjectPermission::hasPermission( $file->id(), "filemanager_file", "r", $user)==false) $fileName
Definition: ezfilemanager/user/filedownload.php:43
$timestamp
$timestamp
Definition: ezstats/admin/cron.php:35
$time
$time
Definition: homepage.php:327
$warning
$warning
Definition: sectionedit.php:95
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.