| @@ 32-50 (lines=19) @@ | ||
| 29 | * @return string |
|
| 30 | * @throws Exception\InvalidArgumentException |
|
| 31 | */ |
|
| 32 | public static function validateLogFile($logFile, $logDir) |
|
| 33 | { |
|
| 34 | // Is logFile a stream url? |
|
| 35 | if (strpos($logFile, '://') !== false) { |
|
| 36 | return $logFile; |
|
| 37 | } |
|
| 38 | ||
| 39 | if (! file_exists($logDir) || ! is_writable($logDir)) { |
|
| 40 | throw new Exception\InvalidArgumentException("Log dir {$logDir} must exist and be writable!"); |
|
| 41 | } |
|
| 42 | ||
| 43 | $fileName = $logDir.DIRECTORY_SEPARATOR.$logFile; |
|
| 44 | ||
| 45 | if (file_exists($fileName) && ! is_writable($fileName)) { |
|
| 46 | throw new Exception\InvalidArgumentException("Log file {$fileName} must be writable!"); |
|
| 47 | } |
|
| 48 | ||
| 49 | return $fileName; |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 42-60 (lines=19) @@ | ||
| 39 | * @return string |
|
| 40 | * @throws Exception\InvalidArgumentException |
|
| 41 | */ |
|
| 42 | public static function validateLogFile($logFile, $logDir) |
|
| 43 | { |
|
| 44 | // Is logFile a stream url? |
|
| 45 | if (strpos($logFile, '://') !== false) { |
|
| 46 | return $logFile; |
|
| 47 | } |
|
| 48 | ||
| 49 | if (! file_exists($logDir) || ! is_writable($logDir)) { |
|
| 50 | throw new Exception\InvalidArgumentException("Log dir {$logDir} must exist and be writable!"); |
|
| 51 | } |
|
| 52 | ||
| 53 | $fileName = $logDir.DIRECTORY_SEPARATOR.$logFile; |
|
| 54 | ||
| 55 | if (file_exists($fileName) && ! is_writable($fileName)) { |
|
| 56 | throw new Exception\InvalidArgumentException("Log file {$fileName} must be writable!"); |
|
| 57 | } |
|
| 58 | ||
| 59 | return $fileName; |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||