diff options
author | Bart Visscher <bartv@thisnet.nl> | 2013-08-28 17:41:27 +0200 |
---|---|---|
committer | Bart Visscher <bartv@thisnet.nl> | 2013-08-28 17:41:27 +0200 |
commit | 3fd2df4088d17547a3a31023a75cf538c95ade18 (patch) | |
tree | b817b924800e9043aa5450e937181df1c7380a00 /lib/log/rotate.php | |
parent | 42f3ecb60fb14ef9739b436f115d302b5d4432a1 (diff) | |
download | nextcloud-server-3fd2df4088d17547a3a31023a75cf538c95ade18.tar.gz nextcloud-server-3fd2df4088d17547a3a31023a75cf538c95ade18.zip |
Only enable logrotate when configured. Also rotate size is settable.
Diffstat (limited to 'lib/log/rotate.php')
-rw-r--r-- | lib/log/rotate.php | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/log/rotate.php b/lib/log/rotate.php index 41ef2ea299c..b620f0be15c 100644 --- a/lib/log/rotate.php +++ b/lib/log/rotate.php @@ -10,24 +10,26 @@ namespace OC\Log; /** * This rotates the current logfile to a new name, this way the total log usage - * will stay limited and older entries are available for a while longer. The - * total disk usage is twice LOG_SIZE_LIMIT. + * will stay limited and older entries are available for a while longer. * For more professional log management set the 'logfile' config to a different * location and manage that with your own tools. */ class Rotate extends \OC\BackgroundJob\Job { - const LOG_SIZE_LIMIT = 104857600; // 100 MiB + private $max_log_size; public function run($logFile) { - $filesize = @filesize($logFile); - if ($filesize >= self::LOG_SIZE_LIMIT) { - $this->rotate($logFile); + $this->max_log_size = OC_Config::getValue('log_rotate_size', false); + if ($this->max_log_size) { + $filesize = @filesize($logFile); + if ($filesize >= $this->max_log_size) { + $this->rotate($logFile); + } } } protected function rotate($logfile) { $rotatedLogfile = $logfile.'.1'; rename($logfile, $rotatedLogfile); - $msg = 'Log file "'.$logfile.'" was over 100MB, moved to "'.$rotatedLogfile.'"'; + $msg = 'Log file "'.$logfile.'" was over '.$this->max_log_size.' bytes, moved to "'.$rotatedLogfile.'"'; \OC_Log::write('OC\Log\Rotate', $msg, \OC_Log::WARN); } } |