Mon Apr 16 07:02:12 2018 [15900][412b8e70-febc-11e6-934a-52d504b662cb][FATAL] No Links found for relationship tasks_activities_1_tasks Mon Apr 16 07:02:12 2018 [15900][420703ed-f2bc-e3f4-f906-566ef6f1e16d][FATAL] No Links found for relationship accounts_accounts_1 Mon Apr 16 07:02:12 2018 [15900][41a5d4a2-c01b-11e7-88b5-52d504b662cb][FATAL] No Links found for relationship cases_cases_1
Usually I am looking for an entry from a particular user so GUIDs are hard for old human eyes to read. Even with FIND its a pain. So I wrote this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!defined('sugarEntry'))define('sugarEntry', true); | |
chdir(dirname(__FILE__)); | |
define('ENTRY_POINT_TYPE', 'api'); | |
require_once('include/entryPoint.php'); | |
$sapi_type = php_sapi_name(); | |
if (substr($sapi_type, 0, 3) != 'cli') { | |
sugar_die("logUpdate.php is CLI only."); | |
} | |
SugarMetric_Manager::getInstance()->setMetricClass('background')->setTransactionName('cron'); | |
if(empty($current_language)) { | |
$current_language = $sugar_config['default_language']; | |
} | |
$app_list_strings = return_app_list_strings_language($current_language); | |
$app_strings = return_application_language($current_language); | |
global $current_user; | |
$current_user = BeanFactory::getBean('Users'); | |
$current_user->getSystemUser(); | |
$sql = "SELECT id, user_name, is_admin, status FROM users"; | |
$result=$GLOBALS['db']->query($sql, true); | |
if(file_exists('updateLog.sh')) unlink('updateLog.sh'); | |
$fp = fopen('updateLog.sh','w'); | |
while($hash=$GLOBALS['db']->fetchByAssoc($result)) { | |
if($hash['is_admin']) $hash['user_name'] .= '*'; | |
if($hash['id']!=1) { | |
fwrite($fp, "sed -i .bak 's/{$hash['id']}/{$hash['user_name']} ({$hash['status']})/g' \"sugarcrm.log\"\n"); | |
} | |
unlink('sugarcrm.log.bak'); | |
} | |
fclose($fp); |
So to use this you need to
- Copy this code to the root SugarCRM directory
- run it (php -f updateLog.php)
- Update the permissions on the file it creates (chmod 777 updateLog.sh)
- Run the script (./updateLog.sh)
This could also be done in real time by overriding include/SugarLoggger/SugarLogger.php and changing the bit of code that write the line to the log file. I can show that if anyone needs it, just ask.
No comments:
Post a Comment