Skip to content

Commit

Permalink
Default log file to project root
Browse files Browse the repository at this point in the history
  • Loading branch information
pravesh-a committed Nov 26, 2019
1 parent 2c80249 commit dd3ed7c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/crm/utility/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ public static function writeToFile($msg)
{
$path = trim(ZCRMConfigUtil::getConfigValue(APIConstants::APPLICATION_LOGFILE_PATH));
if (!ZCRMConfigUtil::getConfigValue(APIConstants::APPLICATION_LOGFILE_PATH)) {
$path=posix_getpwuid(posix_getuid())["dir"];
$dir_path = __DIR__;
if(strpos($dir_path, "vendor")!==false){
$path = substr($dir_path,0, strpos($dir_path, "vendor")-1);
}
else{
$path = substr($dir_path,0, strpos($dir_path, "src")-1);
}
}
$filePointer = fopen($path . APIConstants::APPLICATION_LOGFILE_NAME, "a");
if (! $filePointer) {
return;
return;
}
fwrite($filePointer, sprintf("%s %s\n", date("Y-m-d H:i:s"), $msg));
fclose($filePointer);
Expand Down

0 comments on commit dd3ed7c

Please sign in to comment.