2015-10-31 14:27:16 +00:00
|
|
|
module.exports = function (logsManager) {
|
|
|
|
return {
|
|
|
|
index: function(req, res){
|
|
|
|
logsManager.logFiles(function (err, files) {
|
|
|
|
if (err) {
|
|
|
|
res.send(err);
|
|
|
|
} else {
|
|
|
|
res.send(files);
|
|
|
|
}
|
2014-09-28 08:50:03 +00:00
|
|
|
});
|
2015-10-31 14:27:16 +00:00
|
|
|
},
|
|
|
|
show: function(req, res){
|
|
|
|
var requestedFilename = req.params.log;
|
|
|
|
if (req.format) {
|
|
|
|
requestedFilename += "." + req.format;
|
2014-09-28 08:50:03 +00:00
|
|
|
}
|
|
|
|
|
2015-10-31 14:27:16 +00:00
|
|
|
logs.getLogFile(requestedFilename, function (err, file) {
|
|
|
|
if (err) {
|
|
|
|
res.send(err);
|
|
|
|
} else {
|
|
|
|
if (file) {
|
|
|
|
res.download(file.path);
|
|
|
|
} else {
|
|
|
|
res.send(404, new Error("File not found"));
|
2014-09-28 08:50:03 +00:00
|
|
|
}
|
2015-10-31 14:27:16 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
2014-09-28 08:50:03 +00:00
|
|
|
};
|