eZ Publish  [4.0]
ezpaymentlogger.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZPaymentLogger class
00004 //
00005 // Created on: <11-Jun-2004 14:18:58 dl>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*! \file ezpaymentlogger.php
00032 */
00033 
00034 /*!
00035   \class eZPaymentLogger
00036 */
00037 
00038 class eZPaymentLogger
00039 {
00040     function eZPaymentLogger( $fileName, $mode )
00041     {
00042         $this->file = fopen( $fileName, $mode );
00043     }
00044 
00045     static function CreateNew($fileName)
00046     {
00047         return new eZPaymentLogger( $fileName, "wt" );
00048     }
00049 
00050     static function CreateForAdd($fileName)
00051     {
00052         return new eZPaymentLogger( $fileName, "a+t" );
00053     }
00054 
00055     function writeString( $string, $label='' )
00056     {
00057         if( $this->file )
00058         {
00059             if ( is_object( $string ) || is_array( $string ) )
00060                 $string = eZDebug::dumpVariable( $string );
00061 
00062             if( $label == '' )
00063                 fputs( $this->file, $string."\r\n" );
00064             else
00065                 fputs( $this->file, $label . ': ' . $string."\r\n" );
00066         }
00067     }
00068 
00069     function writeTimedString( $string, $label='' )
00070     {
00071         if( $this->file )
00072         {
00073             $time = $this->getTime();
00074 
00075             if ( is_object( $string ) || is_array( $string ) )
00076                 $string = eZDebug::dumpVariable( $string );
00077 
00078             if( $label == '' )
00079                 fputs( $this->file, $time. '  '. $string. "\n" );
00080             else
00081                 fputs( $this->file, $time. '  '. $label. ': '. $string. "\n" );
00082         }
00083     }
00084 
00085     static function getTime()
00086     {
00087         $time = strftime( "%d-%m-%Y %H-%M" );
00088         return $time;
00089     }
00090 
00091     public $file;
00092 }
00093 ?>