Commit 7303d340 authored by Efthymia Bika's avatar Efthymia Bika
Browse files

Add logging

Write duplicity output to log files
parent eb548d30
......@@ -21,6 +21,9 @@
res_file_illegal: 'Invalid Entry. Provide a valid file name',
path_empty: 'Provide a path'
};
var dup_verbosity = " -v8 ";
var mkdirp = require("mkdirp");
var exec = require('child_process').exec;
load_data_from_file(BACKUP_CONF_FILE, render_backup_sets);
......@@ -331,7 +334,6 @@
if(restore) {
if(file_to_restore) {
directory = path.join($("#res-directory").html(), file_to_restore);
var mkdirp = require("mkdirp");
mkdirp(directory, function(err) {
if(err) console.error(err);
});
......@@ -341,6 +343,9 @@
} else {
directory = $("#directory").html();
}
var log_file = path.join(BAAS_LOG_DIR, "dup_" + new Date().toISOString() + ".log");
var log_arg = " --log-file '" + log_file + "' ";
if(process.platform == 'win32') {
directory = directory.replace(/\\/g, "\\\\");
exec(CYGWIN_BASH + " -c \"/usr/bin/cygpath '" + directory + "' \"",
......@@ -353,7 +358,7 @@
dirs = " swift://" + container + " " + directory;
}
var cmd = build_win_commands();
var dup_cmd = "duplicity " + include_arg + exclude_arg + file_arg + time_arg + dirs + ";";
var dup_cmd = "duplicity " + dup_verbosity + log_arg + include_arg + exclude_arg + file_arg + time_arg + dirs + ";";
exec(CYGWIN_BASH + " -c '" + cmd + dup_cmd + "'",
function(error, stdout, stderr){
......@@ -369,11 +374,12 @@
});
} else {
set_envs();
var dirs = directory + " swift://" + container;
if(restore) {
dirs = " swift://" + container + " " + directory;
}
var dup_cmd = "duplicity " + include_arg + exclude_arg + file_arg + time_arg + dirs + ";";
var dup_cmd = "duplicity " + dup_verbosity + log_arg + include_arg + exclude_arg + file_arg + time_arg + dirs + ";";
exec(dup_cmd , function(error, stdout, stderr) {
if(error) {
$("#msg").addClass("panel");
......@@ -544,7 +550,6 @@
.attr("id", "timeview-contents-list");
var contents = JSON.parse(stdout);
$.each(contents, function(i, el) {
console.log(el.type);
var icon_class = (el.type == 'dir') ? "fa fa-folder yellow-folder" : "fa fa-file-text-o green-file";
var li = $("<li><i class='" + icon_class + "'></i>&nbsp;" + el.name + "</li>")
.attr("id", el.name);
......
......@@ -4,6 +4,7 @@ var path = require('path');
var BAAS_HOME_DIR = '.baas';
var CLOUDS_CONF_FILE = 'clouds.rc';
var BACKUP_CONF_FILE = 'backups.rc';
var BAAS_LOG_DIR = path.join(get_user_home(), BAAS_HOME_DIR, 'log');
var exec_path = path.dirname(process.execPath);
var CYGWIN_BASH = path.join(exec_path, "bin", "bash.exe");
......@@ -22,6 +23,7 @@ function create_baas_dir() {
// Create conf files under new directory
create_conf_file(CLOUDS_CONF_FILE);
create_conf_file(BACKUP_CONF_FILE);
create_log_dir();
});
return;
}
......@@ -71,3 +73,18 @@ function load_data_from_file(filename, callback) {
});
});
}
function create_log_dir() {
fs.stat(BAAS_LOG_DIR, function (err, stats) {
if(err) {
fs.mkdir(BAAS_LOG_DIR, function(error) {
if(error) return console.error(error);
console.log("Successfully created " + BAAS_LOG_DIR);
});
return;
}
if(stats.isFile()) {
return console.error("Failed to create " + BAAS_LOG_DIR + ", File exists.");
}
});
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment