Skip to content

Commit dd3ed7c

Browse files
committed
Default log file to project root
1 parent 2c80249 commit dd3ed7c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/crm/utility/Logger.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,17 @@ public static function writeToFile($msg)
88
{
99
$path = trim(ZCRMConfigUtil::getConfigValue(APIConstants::APPLICATION_LOGFILE_PATH));
1010
if (!ZCRMConfigUtil::getConfigValue(APIConstants::APPLICATION_LOGFILE_PATH)) {
11-
$path=posix_getpwuid(posix_getuid())["dir"];
11+
$dir_path = __DIR__;
12+
if(strpos($dir_path, "vendor")!==false){
13+
$path = substr($dir_path,0, strpos($dir_path, "vendor")-1);
14+
}
15+
else{
16+
$path = substr($dir_path,0, strpos($dir_path, "src")-1);
17+
}
1218
}
1319
$filePointer = fopen($path . APIConstants::APPLICATION_LOGFILE_NAME, "a");
1420
if (! $filePointer) {
15-
return;
21+
return;
1622
}
1723
fwrite($filePointer, sprintf("%s %s\n", date("Y-m-d H:i:s"), $msg));
1824
fclose($filePointer);

0 commit comments

Comments
 (0)