diff --git a/core/class/jeedom.class.php b/core/class/jeedom.class.php index b0d465631a..23cb83b270 100644 --- a/core/class/jeedom.class.php +++ b/core/class/jeedom.class.php @@ -1293,6 +1293,13 @@ public static function cronHourly() { } catch (Error $e) { log::add('jeedom', 'error', $e->getMessage()); } + try{ + log::chunk('', True); + }catch (Exception $e) { + log::add('jeedom', 'error', $e->getMessage()); + } catch (Error $e) { + log::add('jeedom', 'error', $e->getMessage()); + } } /*************************************************************************************/ diff --git a/core/class/log.class.php b/core/class/log.class.php index 7417b366a5..f8909c7663 100644 --- a/core/class/log.class.php +++ b/core/class/log.class.php @@ -124,13 +124,14 @@ public static function add($_log, $_type, $_message, $_logicalId = '') { } } - public static function chunk($_log = '') { + public static function chunk($_log = '', $_onlyIfSizeExceeded = False) { $paths = array(); if ($_log != '') { $paths = array(self::getPathToLog($_log)); } else { $relativeLogPaths = array('', 'scenarioLog/'); foreach ($relativeLogPaths as $relativeLogPath) { + $logPath = self::getPathToLog($relativeLogPath); $logs = ls($logPath, '*'); foreach ($logs as $log) { @@ -139,9 +140,12 @@ public static function chunk($_log = '') { } } foreach ($paths as $path) { - if (is_file($path)) { - self::chunkLog($path); - } + if (is_file($path)) { + if($_onlyIfSizeExceeded && filesize($path) < (self::getConfig('maxSizeLog') * 1024 * 1024) ){ + continue; + } + self::chunkLog($path); + } } } diff --git a/core/config/default.config.ini b/core/config/default.config.ini index 7bafc45386..7f66a9d2dc 100644 --- a/core/config/default.config.ini +++ b/core/config/default.config.ini @@ -78,6 +78,7 @@ security::whiteips = "127.0.0.1;192.168.*.*;10.*.*.*;172.*.*.*" ;Log maxLineLog = 500 +maxSizeLog = 5 log::level = 400 log::syslogudpport = 514 log::syslogudpfacility = user diff --git a/desktop/php/administration.php b/desktop/php/administration.php index ea1fb1a0a3..febd2d23ac 100644 --- a/desktop/php/administration.php +++ b/desktop/php/administration.php @@ -994,6 +994,12 @@ +