Skip to content

Commit f069ec7

Browse files
committed
add log directory
1 parent 4c0728f commit f069ec7

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lib/task/logClearTask.class.php

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
/**
4+
* Clears log files.
5+
*
6+
* @package symfony
7+
* @subpackage task
8+
* @author Fabien Potencier <[email protected]>
9+
* @version SVN: $Id: sfLogClearTask.class.php 23922 2009-11-14 14:58:38Z fabien $
10+
*/
11+
class logClearTask extends sfBaseTask
12+
{
13+
/**
14+
* @see sfTask
15+
*/
16+
protected function configure()
17+
{
18+
$this->namespace = 'crew';
19+
$this->name = 'clear-log';
20+
$this->aliases = array('ccl');
21+
$this->briefDescription = 'Complete removal of log files (.gitignore file is not erased)';
22+
}
23+
24+
/**
25+
* @see sfTask
26+
*/
27+
protected function execute($arguments = array(), $options = array())
28+
{
29+
if (!sfConfig::get('sf_log_dir') || !is_dir(sfConfig::get('sf_log_dir')))
30+
{
31+
throw new sfException(sprintf('Log directory "%s" does not exist.', sfConfig::get('sf_log_dir')));
32+
}
33+
34+
try
35+
{
36+
$this->getFilesystem()->remove(sfFinder::type('any')
37+
->discard('.gitignore')
38+
->in(sfConfig::get('sf_log_dir'))
39+
);
40+
}
41+
catch(Exception $e)
42+
{
43+
return 1;
44+
}
45+
46+
return 0;
47+
}
48+
}

log/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

0 commit comments

Comments
 (0)