Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento logs print array contents

Mage::log works fine for me, except when it comes to printing array info.

For example, if I have an array $result, and do this:

Mage::log('[CartController: getDeliverLeadTime(country): ' . $result . ')');

In my system.log file I just get: [CartController: getDeliverLeadTime~(country): Array)

*I want it to print the actual structure and contents of the array, as a normal print_r would do.*

If I do a var_dump of the array I get nothing, i.e. [CartController: getDeliverLeadTime~(country): ).

If I do a print_r I get: [CartController: getDeliverLeadTime~(country): 1)

This is a blocker for me as I can't debug what I need to - if anyone could shed any light on how to get Magento to actually print the contents of arrays in the logs, would be much appreciated.

I read on alanstorm.com that its meant to be happen by default, but its not for me.

Thanks Paul

like image 682
pokero Avatar asked Jun 12 '12 09:06

pokero


1 Answers

You have to return print_r as a string, so print_r($result, true) should do the trick.

like image 127
Max Avatar answered Oct 14 '22 04:10

Max