Skip to content
Snippets Groups Projects
Commit 81a0af31 authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Ajust the log levels and details of log messages

make the output less 'chatty'
parent 44ad0d3d
No related branches found
No related tags found
No related merge requests found
Pipeline #7903 passed
......@@ -52,12 +52,12 @@ var now = time();
for(var i in dir_list) {
var dir_code = dir_list[i];
var dir = file_area.dir[dir_code];
log(dir_code);
log(LOG_DEBUG, dir_code);
var base = new FileBase(dir_code);
if(!base.open())
throw new Error(base.last_error);
if(options.offline) {
log("Purging offline files");
log(dir_code + ": Purging offline files");
var list = base.get_names(/* sort: */false);
var removed = 0;
for(var j = 0; j < list.length; j++) {
......@@ -65,7 +65,7 @@ for(var i in dir_list) {
if(exclude.indexOf(file.toUpperCase()) >= 0)
continue;
if(base.get_size(file) < 0) {
log("Removing offline file: " + base.get_path(file));
log(LOG_INFO, dir_code + ": Removing offline file: " + base.get_path(file));
if(options.test)
removed++;
else {
......@@ -76,11 +76,12 @@ for(var i in dir_list) {
}
}
}
log("Removed " + removed + " offline files");
if(removed)
log(LOG_NOTICE, dir_code + ": Removed " + removed + " offline files");
}
var max_age = base.max_age || dir.max_age;
if(max_age) {
log("Purging old files, imposing max age of " + max_age + " days");
log(dir_code + ": Purging old files, imposing max age of " + max_age + " days");
var list = base.get_list(FileBase.DETAIL.NORM, /* sort: */false);
var removed = 0;
for(var j = 0; j < list.length; j++) {
......@@ -96,7 +97,7 @@ for(var i in dir_list) {
}
var file_age = Math.floor((now - t) / (24 * 60 * 60));
if(file_age > max_age) {
log("Removing " + base.get_path(file.name) + " " + age_desc + " " + file_age + " days ago");
log(LOG_INFO, dir_code + ": Removing " + base.get_path(file.name) + " " + age_desc + " " + file_age + " days ago");
if(options.test)
removed++;
else {
......@@ -107,11 +108,13 @@ for(var i in dir_list) {
}
}
}
log("Removed " + removed + " of " + list.length + " files due to age of " + max_age + " days");
if(removed)
log(LOG_NOTICE, ": Removed " + removed + " of " + list.length + " files due to age of " + max_age + " days");
}
var max_files = base.max_files || dir.max_files;
if(max_files) {
log("Purging excess files, imposing max files limit of " + max_files);
var tfiles = file_area.dir[dir_code].files;
if(max_files && tfiles > max_files) {
log(dir_code + ": Purging excess files, imposing max files limit of " + max_files + " in area with " + tfiles + " files");
var list = base.get_list(FileBase.DETAIL.MIN, /* sort: */false);
var removed = 0;
var excess = list.length - max_files;
......@@ -119,7 +122,7 @@ for(var i in dir_list) {
var file = list[j];
if(exclude.indexOf(file.name.toUpperCase()) >= 0)
continue;
log("Removing " + file.name);
log(LOG_INFO, dir_code + ": Removing " + file.name);
if(options.test)
removed++;
else {
......@@ -129,7 +132,8 @@ for(var i in dir_list) {
removed++;
}
}
log("Removed " + removed + " of " + list.length + " files due to max file limit of " + max_files);
if(removed)
log(LOG_NOTICE, ": Removed " + removed + " of " + list.length + " files due to max file limit of " + max_files);
}
base.close();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment