PHP Class BugReporter

An object for sending captured error info to an HTTP server. An object for sending captured error info to an HTTP server. In particular this is made to work with the Trac plugin Autotrac, though it would be quite simple to make another HTTP server to work with it. A simple way to use this object is to create an error handler to the following function report_bug(): function report_bug ($p_number, $p_string, $p_file, $p_line) { $reporter = new BugReporter ($p_number, $p_string, $p_file, $p_line); $reporter->setServer ("http://myserver.com/mydirectory") $reporter->sendToServer(); } The errors are always sent to the server URL plus the extension "/report". So the above example would POST the error variables to http://myserver.com/mydirectory/newreport . The error variables POSTed are: - f_backtrace - f_id - f_software - f_str - f_num - f_file - f_line - f_backtrace * - f_description - f_email
ファイルを表示 Open project: sourcefabric/newscoop Class Usage Examples

Public Methods

Method Description
__construct ( integer $p_number, string $p_string, string $p_file, integer $p_line, string $p_software, integer $p_version, string $p_time = "", mixed $p_backtrace = "" )
__convertBacktraceArrayToString ( array $p_backtrace ) : string Convert the backtrace array into a backtrace string.
getBacktraceString ( ) : string Get the backtrace string.
getDescription ( ) : integer Get the error reporter's description of the error.
getEmail ( ) : integer Get the error reporter's email address
getErrorNum ( ) : integer Get the number of the error.
getFile ( ) : string Get the name of the file in which the error occerrud.
getFileWithoutPath ( ) : string Return the name of the error-file, not including the path.
getFormToken ( $p_client ) : mixed Get form token to protect against CSRF attacks.
getId ( ) : string Get the Error ID Code
getLine ( ) : integer Get the line number the error occurred in.
getPHPVersion ( ) : string Gets PHP version
getPingStatus ( ) : The
getServer ( ) : string Returns the current developers' server.
getServerOS ( ) : string Gets OS info
getSoftware ( ) : string Get the name of the software the error occurred in.
getStr ( ) : The Get the error message
getTime ( ) : string Get the time of the error.
getVersion ( ) : string Get the version of the software the error occurred in.
setBacktraceString ( $p_backtrace ) : void Get Manually set the backtrace string.
setDescription ( $p_description ) : void Set the reporter's description of the error
setEmail ( $p_email ) : void Set the error reporter's email address.
setErrorNum ( $p_errorNum ) : void Manually set the number of the error which occurred.
setFile ( $p_file ) : void Manually set the file in which the error occurred.
setLine ( $p_line ) : void Manually set the line number in which the error occurred.
setPingStatus ( $p_pingingStatus ) : void When pinging status is is set to false, pingServer() returns true without actually pinging the server.
setServer ( string $p_server ) : void This changes the developers' default server.
setSoftware ( $p_software ) : void Manually set the software in which the error occurred.
setStr ( $p_str ) : void Manually set the message of the error which occurred.
setTime ( $p_time ) : void Manually set the time at which the error occurred.
setVersion ( $p_version ) : void Manually set the software version of the error which occurred.

Method Details

__construct() public method

public __construct ( integer $p_number, string $p_string, string $p_file, integer $p_line, string $p_software, integer $p_version, string $p_time = "", mixed $p_backtrace = "" )
$p_number integer The PHP error number.
$p_string string The error message.
$p_file string The file which encountered the error.
$p_line integer The line number of the file which encountered the error.
$p_software string The name of the software that encountered an error.
$p_version integer The version of the software that encountered an error.
$p_time string The date and time. If left blank, it is the current date and time.
$p_backtrace mixed The stack trace. This can be an array or string.

__convertBacktraceArrayToString() public method

Convert the backtrace array into a backtrace string.
public __convertBacktraceArrayToString ( array $p_backtrace ) : string
$p_backtrace array array The array to be converted.
return string The array as a string.

getBacktraceString() public method

Get the backtrace string.
public getBacktraceString ( ) : string
return string The traceback

getDescription() public method

Get the error reporter's description of the error.
public getDescription ( ) : integer
return integer Get the user's description of the error

getEmail() public method

Get the error reporter's email address
public getEmail ( ) : integer
return integer Get the email address of the user.

getErrorNum() public method

Get the number of the error.
public getErrorNum ( ) : integer
return integer The error number

getFile() public method

Get the name of the file in which the error occerrud.
public getFile ( ) : string
return string The name of the file the crash occurred in.

getFileWithoutPath() public method

Return the name of the error-file, not including the path.
public getFileWithoutPath ( ) : string
return string The name of the file, not including the path.

getFormToken() public method

Get form token to protect against CSRF attacks.
public getFormToken ( $p_client ) : mixed
return mixed String The form token False If the no token was get.

getId() public method

Get the Error ID Code
public getId ( ) : string
return string the file's ID-code.

getLine() public method

Get the line number the error occurred in.
public getLine ( ) : integer
return integer The line number the error occurred in.

getPHPVersion() public method

Gets PHP version
public getPHPVersion ( ) : string
return string php version

getPingStatus() public method

public getPingStatus ( ) : The
return The pinging status

getServer() public method

Returns the current developers' server.
public getServer ( ) : string
return string The current server's URL.

getServerOS() public method

Gets OS info
public getServerOS ( ) : string
return string OS info

getSoftware() public method

Get the name of the software the error occurred in.
public getSoftware ( ) : string
return string The name of the software the error occurred in.

getStr() public method

Get the error message
public getStr ( ) : The
return The error-string

getTime() public method

Get the time of the error.
public getTime ( ) : string
return string The time at which the crash occurred

getVersion() public method

Get the version of the software the error occurred in.
public getVersion ( ) : string
return string The version of the software the error occurred in

setBacktraceString() public method

Get Manually set the backtrace string.
public setBacktraceString ( $p_backtrace ) : void
return void

setDescription() public method

Set the reporter's description of the error
public setDescription ( $p_description ) : void
return void

setEmail() public method

Set the error reporter's email address.
public setEmail ( $p_email ) : void
return void

setErrorNum() public method

Manually set the number of the error which occurred.
public setErrorNum ( $p_errorNum ) : void
return void

setFile() public method

Manually set the file in which the error occurred.
public setFile ( $p_file ) : void
return void

setLine() public method

Manually set the line number in which the error occurred.
public setLine ( $p_line ) : void
return void

setPingStatus() public method

When pinging status is is set to false, pingServer() returns true without actually pinging the server.
public setPingStatus ( $p_pingingStatus ) : void
return void

setServer() public method

This changes the developers' default server.
public setServer ( string $p_server ) : void
$p_server string The URL of the new server.
return void

setSoftware() public method

Manually set the software in which the error occurred.
public setSoftware ( $p_software ) : void
return void

setStr() public method

Manually set the message of the error which occurred.
public setStr ( $p_str ) : void
return void

setTime() public method

Manually set the time at which the error occurred.
public setTime ( $p_time ) : void
return void

setVersion() public method

Manually set the software version of the error which occurred.
public setVersion ( $p_version ) : void
return void