예제 #1
0
function setAppLog() {
  PkLibConfig::setSuppressPkDebug(false);
  $logDir = realpath(storage_path().'/logs');
  $logPath = $logDir.'/pkapp.log';
  appLogPath($logPath);
}
예제 #2
0
/** Sets the path and name for the debug log IF 
 * PkLibConfig::getSuppressPkDebug() is FALSE
 * @staticvar type $logpath
 * @param type $path
 * @return string
 */
function appLogPath($path = null) {
  if (PkLibConfig::getSuppressPkDebug()) {
    error_log("Debug Suppressed - No Log");
    return getNullPath();
  }
  if (isCli()) {
    $base = __DIR__;
  } else {
    $base = $_SERVER['DOCUMENT_ROOT'] . '/..';
  }
  $defaultPath = $base . '/logs/app.log';
  static $logpath = null;
  error_log("defaultPath: [$defaultPath]");
  if ($path === false) {
    $logpath = $defaultPath;
    $res = makePathToFile($logpath);
    error_log("The used log path...$logpath");
    return $logpath;
  }
  if (!$path) {
    if (!$logpath) {
      $logpath = $defaultPath;
    }
    $res = makePathToFile($logpath);
    error_log("The used log path...$logpath");
    return $logpath;
  }
  $logpath = $path;
  $res = makePathToFile($logpath);
    error_log("The used log path...$logpath");
  return $logpath;
}