Gumbo PHP Library API Documentation
Debug
[
class tree
] [
index
] [
all elements
]
Todo List
Packages:
Buffer
Collection
Composite
Config
Converter
Curl
Date
DB
Debug
Encryption
Error
Factory
Filter
Flyweight
Http
Input
Iterator
List
Load
Lockable
Log
Map
Number
Observer
Output
Query
Record
Router
Session
Setting
Singleton
Template
Timer
Utility
Valid
Source for file File.class.php
Documentation is available at
File.class.php
<?php
/**
* Gumbo Library Framework
*
* LICENSE
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
*
*
@category
Gumbo
*
@package
Debug
*
@copyright
Copyright (c) 2007, iBayou, Michael Luster
*
@license
http://www.opensource.org/licenses/bsd-license.php New BSD License
*
@author
Michael Luster <mluster79@yahoo.com>
*
@link
http://sourceforge.net/projects/phpgumbo
*
@version
0.0.1
*/
/**
* Debug File Report Class
*
*
@category
Gumbo
*
@package
Debug
*
@copyright
Copyright (c) 2007, iBayou, Michael Luster
*
@license
http://www.opensource.org/licenses/bsd-license.php New BSD License
*
@author
Michael Luster <mluster79@yahoo.com>
*
@link
http://sourceforge.net/projects/phpgumbo
*
@desc
Debug File Report Class
*
@version
0.0.1
*/
gumbo_load
(
"Debug_Report"
)
;
gumbo_load
(
"Date"
)
;
class
Gumbo_Debug_Report_File
extends
Gumbo_Debug_Report
{
/**
@var
string
$_file
Debug File */
private
$_file
;
/**
* Constructor
*
@param
string
$file
(full path)
*/
public
function
__construct
(
$file
=
null
)
{
if
(
defined
(
"GUMBO_DEBUG_FILE"
))
{
$this
->
setFile
(
GUMBO_DEBUG_FILE
)
;
}
if
(
!
is_null
(
$file
))
{
$this
->
setFile
(
$file
)
;
}
}
/** ACTION METHODS **/
/**
* Runs the Report
*
@param
num
$start_time
initial start time of script debugger
*
@throws
Gumbo_Exception
*
@uses
Gumbo_Date
*/
public
function
run
(
$start_time
=
null
)
{
try
{
// verify precondition
if
(
!
$this
->
getFile
(
))
{
throw
new
Gumbo_Exception
(
"Debug File Undefined"
)
;
}
$fp
=
@
fopen
(
$this
->
getFile
(
)
,
"a+"
)
;
$date
=
new
Gumbo_Date
(
)
;
fwrite
(
$fp
,
"\n"
.
$date
->
get
(
)
.
"\n"
)
;
foreach
(
$this
->
getMessages
(
)
as
$mess
)
{
$mess
->
setSeconds
(
$start_time
)
;
$txt
=
$mess
->
getSeconds
(
)
.
"||"
.
$mess
->
getMessage
(
)
.
"||"
;
$txt
.=
$mess
->
getFile
(
)
.
"||"
.
$mess
->
getLine
(
)
.
"||"
;
$txt
.=
$mess
->
getFunction
(
)
.
"||"
.
$mess
->
getClass
(
)
.
"\n"
;
fwrite
(
$fp
,
$txt
)
;
$start_time
=
$mess
->
getTime
(
)
;
}
fwrite
(
$fp
,
"\n"
)
;
fclose
(
$fp
)
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/** MUTATOR METHODS **/
/**
* Sets the Debug File Path
*
@param
string
$file
*
@throws
Gumbo_Exception
*/
public
function
setFile
(
$file
)
{
try
{
// verify precondition
if
(
!
is_string
(
$file
))
{
throw
new
Gumbo_Exception
(
"
Invalid
Argument
'
file
:
str
' => {
$file
}
:
"
.
gettype
(
$file
))
;
}
$this
->
_file
=
$file
;
}
catch
(
Gumbo_Exception
$e
)
{
$e
->
setFunction
(
__METHOD__
)
;
gumbo_trigger
(
$e
)
;
}
}
/** ACCESSOR METHODS **/
/**
* Returns the Debug File name
*
@return
string
*/
public
function
getFile
(
)
{
return
$this
->
_file
;
}
}
?>