-->

Can we create custom logs files in Sugar CRM throu

2019-09-09 19:39发布

问题:

Actually I work on a Sugar CRM package which is for Sugar On Demand. In this package Sugar CRM On Demand does not allow file handling PHP functions But I want to create separate log files for my package.

Is there a way in Sugar CRM to create our separate Custom log files through Sugar CRM internal libraries without disturbing Sugar CRM default logs.

回答1:

You can use the great proposition from Jason, however if you want to stay on your idea to have your own logger you can try that : https://gist.github.com/cmourizard/3e3762bbf709ef4b05e0



回答2:

You probably could, but another solution is to be able to set your package on a different logger level. We do this with SugarChimp and it's extremely helpful. You can have the rest of the application on "debug" while turning your package to "fatal" so that just your logs get logged to sugarcrm.log. You just abstract the built in SugarCRM logger with your own.

So instead of:

$GLOBALS['log']->fatal('MyPackage::my_function check point');

You can do:

MyPackage::log('fatal','MyPackage::my_function check point');

Then in your log function do your logic to check what your package's logger level is set to and call the appropriate SugarLogger function. Also provide a way to change/set that logger level such as through the UI.