Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create log path if it does not exist #63

Open
Bruce17 opened this issue Mar 8, 2017 · 0 comments
Open

Create log path if it does not exist #63

Bruce17 opened this issue Mar 8, 2017 · 0 comments

Comments

@Bruce17
Copy link

Bruce17 commented Mar 8, 2017

Hi,
I configured a log path in my SF2 which does not exist yet (app/logs/scheduler). How about extending the code to try to create the folder first and then check if it's writable (https://github.com/J-Mose/CommandSchedulerBundle/blob/master/Command/ExecuteCommand.php#L95).

Example:

// Before continue, we check that the output file is valid and writable (except for gaufrette)
if (false !== $this->logPath && strpos($this->logPath, 'gaufrette:') !== 0) {
	// Create folder if it does not exist yet.
	// TODO: maybe pass in folder permission and set "0744" (or s.th. else) as fallback.
	if (false === is_dir($this->logPath) && false === mkdir($this->logPath, 0744, true) {
		$output->writeln(
			'<error>Cannot create folder "'.$this->logPath.'". Please change your `log_path` in config.yml'.'</error>'
		);
		return;
	}

	if (false === is_writable($this->logPath)) {
		$output->writeln(
			'<error>'.$this->logPath.
			' not found or not writable. You should override `log_path` in your config.yml'.'</error>'
		);
		return;
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant