PHP code example of sagarchauhan / bugfile
1. Go to this page and download the library: Download sagarchauhan/bugfile library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sagarchauhan / bugfile example snippets
$bug = new BugFile();
$bug->causedBy(BugFile::DEFAULT_USER);
$bug->causedAt(BugFile::DEFAULT_SOURCE);
$bug->setSeverity(BugFile::LOG_INFO);
$bug->customData(BugFile::DEFAULT_DATA);
$bug->log($e);
$bug->setMessage(BugFile::DEFAULT_MESSAGE);
$bug->loggedBy(BugFile::DEFAULT_LOGGER);
$bug->save();
try{
// some logical code
}catch (Exception $e){
$bug = new BugFile();
$bug->causedBy(\Illuminate\Support\Facades\Auth::id());
$bug->causedAt("Login Page");
$bug->setSeverity(BugFile::LOG_INFO);
$bug->customData(['last_login'=>'today']);
$bug->log($e);
$bug->setMessage('Something happened at login function');
$bug->loggedBy('Sagar Chauhan - PM');
$bug->save();
}
#Add these lines just above the switch cases of pimresponse.php
$exceptionHandler->handleException();
$config = [
'APP_ENV'=>'local',
'BUGFILE_END_POINT'=>'https://localhost:8002/api/logs',
'BUGFILE_KEY_DEV'=>'',
'BUGFILE_KEY_STAGING'=>'',
'BUGFILE_KEY_LIVE'=>''
];
try{
// some logical code
}catch (Exception $e){
$bug = new BugFile($config);
$bug->causedBy(\Illuminate\Support\Facades\Auth::id());
$bug->causedAt("Login Page");
$bug->setSeverity(BugFile::LOG_INFO);
$bug->customData(['last_login'=>'today']);
$bug->log($e);
$bug->setMessage('Something happened at login function');
$bug->loggedBy('Sagar Chauhan - PM');
$bug->save();
}