![]() |
Modify the Log message (error, critical exceptions, etc) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: Modify the Log message (error, critical exceptions, etc) (/showthread.php?tid=88692) |
Modify the Log message (error, critical exceptions, etc) - Luppo - 10-19-2023 What is the recommended method to extend the file log to automatically append additional debug information to the log messages (ie IP address and current URL)? I want to keep exactly the same functionality, just adding some dynamic text to the log messages.
RE: Modify the Log message (error, critical exceptions, etc) - InsiteFX - 10-19-2023 You need to extend the system\Log\Logger.php into your app/Libraries Then you would need to add your code to all the method that return the log message. RE: Modify the Log message (error, critical exceptions, etc) - 5flex - 10-29-2023 (10-19-2023, 11:47 AM)Luppo Wrote: It's very simple task... Go to app folder and open exist file Common.php. Add to file: PHP Code: function log_message($level, $message, $context = []): void and on exit you get (as example...): Code: DEBUG - 2023-10-29 07:14:52 --> [192.168.0.1] This your debug message.... Your existing function call log_message() function DON'T NEED CHANGE AT ALL! RE: Modify the Log message (error, critical exceptions, etc) - Luppo - 10-30-2023 (10-29-2023, 06:39 AM)Thanks for the ideas. I ended up extending the FileHandler with a custom hahandle.5flex Wrote:(10-19-2023, 11:47 AM)Luppo Wrote: |