Welcome Guest, Not a member yet? Register   Sign In
Add URL to log_message(...)
#1

(This post was last modified: 09-24-2016, 12:01 AM by John_Betong.)

Is it possible to add the relevant URL to log_message(...)?

Reason being the online ./config/config.php -> $config['log_threshold'] = 1;  only shows the missing file, line number and PHP error.

The error would be far easier to recreate if the offending URL was known.
Reply
#2

(This post was last modified: 09-26-2016, 09:08 PM by John_Betong. Edit Reason: formatting )

(09-23-2016, 07:19 PM)John_Betong Wrote: Is it possible to add the relevant URL to log_message(...)?

Reason being the online ./config/config.php -> $config['log_threshold'] = 1;  only shows the missing file, line number and PHP error.

The error would be far easier to recreate if the offending URL was known.

[SOLVED]

Code:
New Log File:

ERROR - 10:57:07
REQUEST_URL: /home
Severity: error --> Exception: syntax error, unexpected 'function' (T_FUNCTION) /home/john/www/mysite.com/public_html/application/views/v_amp.php 4

Added the following file to ./application/core/MY_Log.php


Code:
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* @package CodeIgniter
* @author  EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT  MIT License
* @link  https://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
defined('BASEPATH') OR exit('No direct script access allowed');

/**
* Logging Class
*
* @package   CodeIgniter
* @subpackage  Libraries
* @category  Logging
* @author    EllisLab Dev Team
* @link    https://codeigniter.com/user_guide/general/errors.html
*/
class MY_Log extends CI_Log {


 // --------------------------------------------------------------------

 /**
  * Format the log line.
  *
  * This is for extensibility of log formatting
  * If you want to change the log format, extend the CI_Log class and override this method
  *
  * @param string  $level  The error level
  * @param string  $date   Formatted date string
  * @param string  $message  The log message
  * @return  string  Formatted log line with a new line character '\n' at the end
  */

 protected function _format_line($level, $date, $message)
 {
   # Added 2016-09-27
     $message  = "\nREQUEST_URL: "
               . $_SERVER['REQUEST_URI']
               . "\n"
               . $message;

   return $level .' - '.$date .$message."\n\n";

   # ORIGINAL
     #return $level.' - '.$date.' --> '.$message."\n";
 }

}
Reply




Theme © iAndrew 2016 - Forum software by © MyBB