can I improve the speed of log_message - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: can I improve the speed of log_message (/showthread.php?tid=11593) |
can I improve the speed of log_message - El Forum - 09-15-2008 [eluser]vlad_ci[/eluser] Hi, while debugging my incomplete app, I am noticing a constant slow down, when using log_message. At first I thought that the new code I added caused the visible slow down (this is just my dev machine running PHP52.apache.postgres and my Music player :- ) A soon as I disable logging, pages show up much faster. I reviewed a couple of postings here, but still did not see something that I could do -- without modifying internals of code igniter. I have seen somewhere a hack to a config.php to allow to show a particular type of messages (instead of 4 and everything below it) ... but cannot find it anymore, that would probably help but not much. So why is this thing so slow? appending to a file of 50 lines per request cannot be that slow, locking the file... I doubt (it is a local file system). Does CI do 'lock file,seek,write' or someething like that for every single time I invoke the log_message? So there may be a different way to pass messages to the log so it goes faster? May be there something like 'flush log' that could put at the destructor of the Controller class, so that writting locking/writting would happen only once per request? thank you can I improve the speed of log_message - El Forum - 09-15-2008 [eluser]Pascal Kriete[/eluser] Disk touching calls will always be slow. You're quite correct in your observation that there is no buffer. In fact, it does quite a bit that might be considered unnecessary, like check if the file exists every time. :: Check for file, get system time, open file, lock, append, unlock, close, chmod. Not the most elegant solution, I'll give you that. Logging is meant for development/debugging so you could argue that it doesn't really need to be fast. And the obvious counter to something like a log-buffer is that log messages can be used to trace where an app is failing. Although I'll take an xdebug stacktrace over the CI log any day. can I improve the speed of log_message - El Forum - 09-15-2008 [eluser]vlad_ci[/eluser] ok, I thought that the CI's logging mechanism is meant to be production ready (since it allows to report errors) and is meant to be used as robust and performance friendly way to get the production-time errors to log files. But looks like , as you are saying, it is development-time debugging facility that must not be used in production. I have luckly encapsulated the call to log_message in my own class so I will just have to change that. If there are any suggestions for production-ready PHP logging facilities I would certainly appreciate any pointers (I am new to the web-dev technologies so there may be something outthere similar to C++ logging libraries or similar) thank you in advance |