Question

I'm developing a module on a vanilla install of CE 1.8.1.0. I'm trying to write to a custom log file inside the module's observer. The log file is created but remains empty no matter what. Here's my code:

app/code/local/My/Module/etc/config.xml:

<config>
    <global>
        ...
    </global>
    <frontend>
        <events>
            <checkout_cart_product_add_after>
                <observers>
                    <my_module>
                        <class>my_module/observer</class>
                        <method>observeSummin</method>
                    </my_module>
                </observers>
            </checkout_cart_product_add_after>
        </events>
    </frontend>
</config>

And the Observer:

app/code/local/My/Module/Model/Observer.php:

class My_Module_Model_Observer
{
    public function observeSummin( $observer ) {
        if ( !$this->_isEnabled ) {
            Mage::log( 'is-enabled, 1: ', 'no', 'my_module.log', true );
            return;
        }

        Mage::log( 'is-enabled, 1: ', 'yes', 'my_module.log', true );

        $quoteItem = $observer->getEvent()->getQuoteItem();

        if ( $this->cartQualifies() ) {
            if ( $quoteItem ) {
                Mage::log( 'cart-qualifies, 1: ', 'yes', 'my_module.log', true );
            }
        } else {
            Mage::log( 'cart-qualifies, 1: ', 'no', 'my_module.log', true );
        }

        return;
    }
}

As you can see, I've just dumped loads of log instances to catch any conditions. Apart from the checkout_cart_product_add_after event, I've also tried hooking into the sales_quote_add_item and checkout_cart_save_after events, with the same results.

If I introduce an intentional code error in the observer, the error log catches it, otherwise, there are none. I've also tried to use Mage::log without the file parameter, but nothing is written to system.log.

The entire var/ folder is chmod 777 and logging is enabled in system config.

I'm lost as to why it's not logging - other Magento events are being logged in system and exception. Any suggestions would be appreciated, thanks!

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top