Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:15:43+00:00 2026-06-12T06:15:43+00:00

I’m trying to customize the logging functionality of codeigniter. I found this forum thread

  • 0

I’m trying to customize the logging functionality of codeigniter. I found this forum thread which describes exactly what I need:
http://codeigniter.com/forums/viewthread/139997/
But I want to do that without altering core files/classes.

I”m trying to alter the log_message function. I’ve already extended the CI_Log class and that is working well, but now I’m trying to alter log_message() which resides in system/core/Common.php. It isn’t actually a class so I can’t extend it, it just appears to be a collection of useful functions. I tried redeclaring log_message() and placing it in application/core/Common.php, but that doesn’t appear to work. Any ideas how I can go about this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:15:44+00:00Added an answer on June 12, 2026 at 6:15 am

    I believe that the function you actually want to alter is write_log(), correct me if I’m wrong. You can do this by extending the function within application\libraries\MY_Log.php.

    I have the following script in my MY_Log.php which emails me any time an error is thrown:

    <?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
    
    /* Extends the logging class to send an email when an error is triggered */
    
    class MY_Log extends CI_Log {
    
        function __construct()
        {
            parent::__construct();
        }
    
        function write_log($level = 'error', $msg, $php_error = FALSE, $additional, $additional2)
    
        {   
            if ($this->_enabled === FALSE)
            {
            return FALSE;
            }
    
             $level = strtoupper($level);
    
            if ( ! isset($this->_levels[$level]) OR ($this->_levels[$level] > $this->_threshold))
            {
            return FALSE;
            }
    
            $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php';
            $message  = '';
    
            if ( ! file_exists($filepath))
            {
            $message .= "<"."?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed'); ?".">\n\n";
            }
    
            if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE))
            {
            return FALSE;
            }
    
            $message .= $level.' '.(($level == 'INFO') ? ' -' : '-').' '.date($this->_date_fmt). ' --> '.$msg."\n";
    
            flock($fp, LOCK_EX);
            fwrite($fp, $message);
            flock($fp, LOCK_UN);
            fclose($fp);
    
            @chmod($filepath, FILE_WRITE_MODE);
            return TRUE;
        }
    
    }
    

    If you’re not looking to extend the write function, you will need to extend one of the other log functions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.