diff options
-rw-r--r-- | system/core/Common.php | 4 | ||||
-rw-r--r-- | system/core/Exceptions.php | 9 | ||||
-rw-r--r-- | user_guide/changelog.html | 1 | ||||
-rw-r--r-- | user_guide/general/errors.html | 4 |
4 files changed, 13 insertions, 5 deletions
diff --git a/system/core/Common.php b/system/core/Common.php index 9dee591e6..2b8ad26b1 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -317,10 +317,10 @@ * @access public * @return void */ - function show_404($page = '') + function show_404($page = '', $log_error = TRUE) { $_error =& load_class('Exceptions', 'core'); - $_error->show_404($page); + $_error->show_404($page, $log_error); exit; } diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index 503015dfd..419ea2b61 100644 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -88,12 +88,17 @@ class CI_Exceptions { * @param string * @return string */ - function show_404($page = '') + function show_404($page = '', $log_error = TRUE) { $heading = "404 Page Not Found"; $message = "The page you requested was not found."; - log_message('error', '404 Page Not Found --> '.$page); + // By default we log this, but allow a dev to skip it + if ($log_error) + { + log_message('error', '404 Page Not Found --> '.$page); + } + echo $this->show_error($heading, $message, 'error_404', 404); exit; } diff --git a/user_guide/changelog.html b/user_guide/changelog.html index 714e9e86e..ce017c9fd 100644 --- a/user_guide/changelog.html +++ b/user_guide/changelog.html @@ -132,6 +132,7 @@ Hg Tag: </p> </li> <li>Other Changes <ul> + <li>Added an optional second parameter to <kbd>show_404()</kbd> to disable logging.</li> <li>Updated loader to automatically apply the sub-class prefix as an option when loading classes. Class names can be prefixed with the standard "CI_" or the same prefix as the subclass prefix, or no prefix at all.</li> <li>Increased randomness with <kbd>is_really_writable()</kbd> to avoid file collisions when hundreds or thousands of requests occur at once.</li> <li>Switched some DIR_WRITE_MODE constant uses to FILE_WRITE_MODE where files and not directories are being operated on.</li> diff --git a/user_guide/general/errors.html b/user_guide/general/errors.html index 7c585d1b9..5bd5011ae 100644 --- a/user_guide/general/errors.html +++ b/user_guide/general/errors.html @@ -76,13 +76,15 @@ about class/function scoping.</p> <p><dfn>application/errors/</dfn><kbd>error_general.php</kbd></p> <p>The optional parameter $status_code determines what HTTP status code should be sent with the error.</p> -<h2>show_404('<var>page</var>')</h2> +<h2>show_404('<var>page</var>' [, '<var>log_error</var>'])</h2> <p>This function will display the 404 error message supplied to it using the following error template:</p> <p><dfn>application/errors/</dfn><kbd>error_404.php</kbd></p> <p>The function expects the string passed to it to be the file path to the page that isn't found. Note that CodeIgniter automatically shows 404 messages if controllers are not found.</p> +<p>CodeIgniter automatically logs any show_404() calls. Setting the optional second parameter to FALSE will skip logging.</p> + <h2>log_message('<var>level</var>', '<samp>message</samp>')</h2> |