Skip to content

Commit

Permalink
[console] Fix logger. (#2874)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolivas authored Nov 2, 2016
1 parent 2c16be7 commit 4d60ce6
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions bin/drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,28 @@
$today = date('Y-m-d');
$loggerFile = $root.'console/log/' . $today . '.log';
$handle = null;
if (!file_exists($loggerFile)){

if (!is_file($loggerFile)) {
try {
mkdir(dirname($loggerFile), 0777, TRUE);
$directoryName = dirname($loggerFile);
if (!is_dir($directoryName )) {
mkdir($directoryName, 0777, TRUE);
}
touch($loggerFile);
} catch (\Exception $e) {
$loggerFile = null;
$loggerOutput = new ConsoleOutput();
}
}
if ($loggerFile) {
if ($loggerFile && is_writable($loggerFile)) {
try {
$handle = fopen($loggerFile, 'a+');
$loggerOutput = new StreamOutput($handle);
} catch (\Exception $e) {
$loggerOutput = new ConsoleOutput();
}
} else {
$loggerOutput = new ConsoleOutput();
}
/* relocate to a class */

Expand Down

0 comments on commit 4d60ce6

Please sign in to comment.