📣 We're Hiring!

Logger is not able to access current user in some scenarios

While working on \include\SugarLogger\SugarLogger.php::log() function. I changed id to user_name.
But in many scenarios, it is not able to log user_name. I mean $GLOBALS[‘current_user’] is not accessible.
Is there any way using which I can achieve this?
I also tried with global $current_user but still no luck.