REQ LOG ENBALED

This commit is contained in:
velz 2019-04-27 15:52:37 +05:30
parent ad3ca5cadc
commit 57edc98b12
5 changed files with 243 additions and 9 deletions

View File

@ -25,6 +25,7 @@ class AUTHORIZATION
set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized");
$response['status']=false;
$response['error']="Invalid token!";
log_message('error','Invalid token!');
echo json_encode($response);
exit;
}
@ -33,6 +34,7 @@ class AUTHORIZATION
set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized");
$response['status'] = false;
$response['message'] = 'Token Experied';
log_message('error','Token Experied');
echo json_encode($response);
exit;
@ -66,6 +68,7 @@ class AUTHORIZATION
set_status_header(REST_CONTROLLER::HTTP_UNAUTHORIZED,"Unauthorized");
$response['status']=false;
$response['error']="Access denied!";
log_message('error','Access denied!');
echo json_encode($response);
exit;
}

View File

@ -6,20 +6,26 @@ class MYLOG
// Create the logger
public static function logFunction() //$msg,$data,$log_type
public static function logFunction($dynamic = null) //$msg,$data,$log_type
{
$channel = $dynamic ? $dynamic : 'ssa_beta_logger';
$log_folder = $dynamic ? 'request_logs' : 'syslogs';
include_once APPPATH.'/vendor/autoload.php';
$logger = new \Monolog\Logger('ssa_beta_logger');
$streamHandler = new \Monolog\Handler\StreamHandler(APPPATH.'syslogs/ssa_app_'.date('Y-m-d').'.html', $logger::DEBUG);
$logger = new \Monolog\Logger($channel);
$streamHandler = new \Monolog\Handler\StreamHandler(APPPATH.$log_folder.'/ssa_app_'.date('Y-m-d').'.html', $logger::DEBUG);
$streamHandler->setFormatter(new \Monolog\Formatter\HtmlFormatter());
$browserHanlder = new \Monolog\Handler\BrowserConsoleHandler($logger);
$logger->pushProcessor(new \Monolog\Processor\WebProcessor());
$logger->pushProcessor(new \Monolog\Processor\IntrospectionProcessor());
$logger->pushProcessor(new \Monolog\Processor\ProcessIdProcessor());
$logger->pushProcessor(new \Monolog\Processor\UidProcessor());
//$logger->pushProcessor(new \Monolog\Processor\HostnameProcessor());
$logger->pushProcessor(new \Monolog\Processor\MemoryUsageProcessor());
$logger->pushProcessor(new \Monolog\Processor\MemoryPeakUsageProcessor());
if(!$dynamic)
{
$logger->pushProcessor(new \Monolog\Processor\IntrospectionProcessor());
$logger->pushProcessor(new \Monolog\Processor\ProcessIdProcessor());
$logger->pushProcessor(new \Monolog\Processor\UidProcessor());
//$logger->pushProcessor(new \Monolog\Processor\HostnameProcessor());
$logger->pushProcessor(new \Monolog\Processor\MemoryUsageProcessor());
$logger->pushProcessor(new \Monolog\Processor\MemoryPeakUsageProcessor());
}
$logger->pushHandler($streamHandler);
return $logger;

View File

@ -1 +1,2 @@
<?php
?>

View File

@ -366,6 +366,25 @@ abstract class REST_Controller extends CI_Controller {
*/
protected function early_checks()
{
$this->load->library('user_agent');
if ($this->agent->is_browser())
{
$agent = $this->agent->browser().' '.$this->agent->version();
}
elseif ($this->agent->is_robot())
{
$agent = $this->agent->robot();
}
elseif ($this->agent->is_mobile())
{
$agent = $this->agent->mobile();
}
else
{
$agent = 'Unidentified User Agent';
}
$logger = MYLOG::logFunction('request_logger');
$logger->info('REQUEST_INFO',array('ip' => $this->input->ip_address(),'paltform' => $this->agent->platform(),'browser' => $agent));
}
/**

View File

@ -0,0 +1,205 @@
<h1 style="background: #468847;color: #ffffff;padding: 5px;" class="monolog-output">INFO</h1><table cellspacing="1" width="100%" class="monolog-output"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Message:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>REQUEST_INFO</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Time:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>2019-04-27 15:34:34</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Channel:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>request_logger</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Context:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">paltform:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Windows 10</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">browser:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Firefox 66.0</pre></td>
</tr></table></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Extra:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">memory_peak_usage:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>3.25 MB</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">memory_usage:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>3.25 MB</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">uid:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>f4965c2</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">process_id:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>10204</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">file:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>C:\5.6\xampp\htdocs\AWSEC2\sparqapi\api\application\libraries\REST_Controller.php</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">line:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>387</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">class:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>REST_Controller</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">function:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>early_checks</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">url:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>/AWSEC2/sparqapi/api/getUsersDetails</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">http_method:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>POST</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">server:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>localhost</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">referrer:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre></pre></td>
</tr></table></td>
</tr></table><h1 style="background: #468847;color: #ffffff;padding: 5px;" class="monolog-output">INFO</h1><table cellspacing="1" width="100%" class="monolog-output"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Message:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>REQUEST_INFO</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Time:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>2019-04-27 15:38:18</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Channel:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>request_logger</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Context:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">paltform:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Windows 10</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">browser:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Firefox 66.0</pre></td>
</tr></table></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Extra:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">file:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>C:\5.6\xampp\htdocs\AWSEC2\sparqapi\api\application\libraries\REST_Controller.php</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">line:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>387</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">class:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>REST_Controller</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">function:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>early_checks</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">url:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>/AWSEC2/sparqapi/api/getUsersDetails</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">http_method:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>POST</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">server:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>localhost</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">referrer:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre></pre></td>
</tr></table></td>
</tr></table><h1 style="background: #468847;color: #ffffff;padding: 5px;" class="monolog-output">INFO</h1><table cellspacing="1" width="100%" class="monolog-output"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Message:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>REQUEST_INFO</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Time:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>2019-04-27 15:38:22</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Channel:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>request_logger</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Context:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">paltform:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Windows 10</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">browser:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Firefox 66.0</pre></td>
</tr></table></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Extra:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">file:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>C:\5.6\xampp\htdocs\AWSEC2\sparqapi\api\application\libraries\REST_Controller.php</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">line:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>387</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">class:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>REST_Controller</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">function:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>early_checks</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">url:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>/AWSEC2/sparqapi/api/getUsersDetails</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">http_method:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>POST</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">server:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>localhost</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">referrer:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre></pre></td>
</tr></table></td>
</tr></table><h1 style="background: #468847;color: #ffffff;padding: 5px;" class="monolog-output">INFO</h1><table cellspacing="1" width="100%" class="monolog-output"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Message:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>REQUEST_INFO</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Time:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>2019-04-27 15:39:12</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Channel:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>request_logger</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Context:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">paltform:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Windows 10</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">browser:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>Firefox 66.0</pre></td>
</tr></table></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">Extra:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><table cellspacing="1" width="100%"><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">url:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>/AWSEC2/sparqapi/api/getUsersDetails</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">ip:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>::1</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">http_method:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>POST</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">server:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre>localhost</pre></td>
</tr><tr style="padding: 4px;text-align: left;">
<th style="vertical-align: top;background: #ccc;color: #000" width="100">referrer:</th>
<td style="padding: 4px;text-align: left;vertical-align: top;background: #eee;color: #000"><pre></pre></td>
</tr></table></td>
</tr></table>