Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    6

    Default Function hook php error log?

    hi all

    I'm writing hooks for the AddonDomain module in php and having trouble. Simple tests work, so I know the hooks are registered ok. Do php errors get logged anywhere?

    cheers
    Rob
    Last edited by robagar; 01-13-2011 at 08:18 PM.

  2. #2
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default Re: Function hook php error log?

    It depends on which ini file you're using and the settings it has.

    If you're following the example from the function hook page, then your shebang line is
    Code:
    #!/usr/bin/php-cgi
    which means we can get the ini file location with
    Code:
    /usr/bin/php-cgi -i |grep --colour 'php.ini'
    <tr><td class="e">error_reporting</td><td class="v">6135</td><td class="v">6135</td></tr>
    Now we know which ini file to look at, /usr/local/lib/php.ini

    What we want to know is
    1) what/where the error log is defined to be
    2) if errors are redirected to the STDOUT
    3) if error reporting is enabled
    4) and if errors are even logged

    Code:
    awk '/(^error_log[[:space:]]?=)|(^display_errors[[:space:]]?=)|(^error_reporting[[:space:]]?=)|(^log_errors[[:space:]]?=)/{print $0};' /usr/local/lib/php.ini
    For my box, I got
    Code:
    display_errors = On
    log_errors = On
    error_log = /usr/local/cpanel/logs/error_log
    but your's is likely to be different. But lets quickly analyze my results.

    1) display_errors is "on". This means that any error message that would normally be sent to an error log will also be sent to STDOUT. This is not something that most people want in a production environment. In the case of function hooks this would not be a good setting since the output is trapped by the invoking cPanel process and will break the cPanel response (if any errors were to occur). Function hooks should never produce anything to STDOUT
    - You can modify this in your script with
    PHP Code:
    ini_set('display_errors'0); 
    - Or better, change the setting in the ini
    - See display_errors in the PHP manual

    2) log_errors is on, meaning that any errors will be send to the "error_log" location.
    - See log_errors

    3) my error_log setting is the standard cPanel error log. This is something that I personally set on my box because it's a convenient place. I think the current default for this value on a cPanel installation is simply "error_log", which is Apache's error log, /usr/local/apache/logs/error_log

    PHP Code:
    ini_set('error_log''/some/place'); 
    - See error_log

    4) Since nothing was returned for error_reporting, the default is applied, "6135" or "E_ALL & ~E_NOTICE"
    - we can confirm this with a grep on the info output
    Code:
    /usr/bin/php-cgi -i |grep --colour error_reporting
    - See error_reporting


    Hope this helps get you going in the right direction.

    Regards,
    -DavidN
    Last edited by cPanelDavidN; 01-14-2011 at 08:16 AM. Reason: clarification of facts
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

  3. #3
    Member
    Join Date
    Jan 2011
    Posts
    6

    Default Re: Function hook php error log?

    Wow! thanks for the comprehensive reply

Similar Threads & Tags
Similar threads

  1. Error log: PHP curl error
    By cyberchimps in forum cPanel and WHM Discussions
    Replies: 3
    Last Post: 05-12-2011, 02:45 PM
  2. Replies: 12
    Last Post: 09-07-2010, 11:34 AM
  3. Replies: 0
    Last Post: 11-08-2009, 02:55 AM
  4. CustomEventHandler / Function Hook
    By jdhf99 in forum cPanel Developers
    Replies: 0
    Last Post: 10-21-2009, 03:22 AM
  5. PHP Fatal error: Call to undefined function: curl_multi_init()
    By thehostinghut in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 07-02-2006, 02:15 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube