Page 1 of 1

debug_log question

Posted: Thu Jun 03, 2010 5:46 pm
by johnhelen
Hi

To know how the application runs in my application, I add some messages using error_log such as

Code: Select all

error_log ("Start the script)";
....
error_log ("End the script)";
And I have this in the application config (Apache virtual host application):
[syntax]
<VirtualHost _default_:*>
..
ErrorLog /home/mycomputer/myapp/logs/apache-error.log
..
[/syntax]
By this way, I can see the application runs when view the file apache-error.log

However, in production server, I do not want to see these messages; I only want to see them in staging and development servers. Could you please tell me how to fix this

Many thanks
john

Re: debug_log question

Posted: Thu Jun 03, 2010 7:18 pm
by Benjamin
:arrow: Moved to PHP - Code

Re: debug_log question

Posted: Thu Jun 03, 2010 10:12 pm
by requinix
Write your own function that checks which server it's on. $_SERVER["SERVER_NAME"] is your friend.

Re: debug_log question

Posted: Mon Jun 07, 2010 5:25 pm
by johnhelen
> Write your own function that checks which server it's on. $_SERVER["SERVER_NAME"] is your friend.

Is there more simple solution? can I have something like debug_log('...."). On staging and development, I can turn debug on but in production server ini, I can set debug off ?

Thanks

Re: debug_log question

Posted: Mon Jun 07, 2010 5:55 pm
by Jonah Bron
This is what tasairis was talking about.

Code: Select all

function my_debug_log($text) {
    if ($_SERVER['SERVER_NAME'] == 'the name of my server') {
        debug_log($text);
    }
}
Another option would be, instead of checking the server name, have it check a constant that you define. This would require you to manually switch, and is probably unnecessary.