I am currently running a websocket
daemon in CodeIgniter 2. The daemon is started using nohup
and runs in an eternal loop. The error output is formatted as HTML. However, I'd like to have the errors logged without HTML formatting. Does CodeIgniter have an option to make this possible?
EDIT: I am not only tracking errors. I am also saving a websocket
log. The log contains functions that have been run and other useful information. I don't want to hide errors from the log though since they may be useful for tracking some errors. I want to log my custom websocket
messages along with errors that may occur.
Daemon start command:
nohup php /usr/share/nginx/html/index.php websocket server > /var/log/websocket/$(date +"%Y%m%d_%H%M%S") 2>&1 &
The errors in the log look like this:
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: REMOTE_ADDR</p>
<p>Filename: core/Input.php</p>
<p>Line Number: 351</p>
I think you're mixing things up a bit, There's the logs and there's the output produced by the page/script.
What you're doing is saving the output from the script into the log, all output, including php errors, notices, warnings and codeigniter's errors(unable to conenct to database).
Codeigniter doesn't have much to do with PHP errors as far as I know, which means this formatting actually comes from the php process itself, you can't prevent this format as far as I know.
If you want to catch all errors, you could suppress all errors and use php's native error_get_last
method, this returns something like this :
Array
(
[type] => 8
[message] => Undefined variable: a
[file] => C:\WWW\index.php
[line] => 2
)
However, should you have a compile error, this method won't work as it needs the code to compile first.
Apache should save automatically the errors for you, I'm pretty sure that can be configured in php.ini but I haven't done that in a while.
In conclusion, I don't think saving the entire output to a log would be the best way to track errors.
Ref to docs : http://php.net/manual/en/function.error-get-last.php