Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions core/class/jeedom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

/*************************************************************************************/
Expand Down
12 changes: 8 additions & 4 deletions core/class/log.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions core/config/default.config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions desktop/php/administration.php
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,12 @@
<input type="text" class="configKey form-control" data-l1key="maxLineLog">
</div>
</div>
<div class="form-group">
<label class="col-lg-4 col-md-4 col-sm-4 col-xs-3 control-label">{{Taille maximale pour fichier de log (en Mo)}}</label>
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-6">
<input type="text" class="configKey form-control" data-l1key="maxSizeLog" />
</div>
</div>
<div class="form-group">
<label class="col-lg-4 col-md-4 col-sm-4 col-xs-3 control-label">{{Niveau de log par défaut}}</label>
<div class="col-lg-3 col-md-4 col-sm-5 col-xs-6">
Expand Down