Merge remote-tracking branch 'origin/master' into socket.io1.x
commit
04175c92d9
@ -0,0 +1,41 @@
|
|||||||
|
"use strict";
|
||||||
|
/* global define, socket */
|
||||||
|
|
||||||
|
define('admin/advanced/logs', function() {
|
||||||
|
var Logs = {};
|
||||||
|
|
||||||
|
Logs.init = function() {
|
||||||
|
var logsEl = $('.logs pre');
|
||||||
|
|
||||||
|
// Affix menu
|
||||||
|
$('.affix').affix();
|
||||||
|
|
||||||
|
$('.logs').find('button[data-action]').on('click', function(e) {
|
||||||
|
var btnEl = $(this),
|
||||||
|
action = btnEl.attr('data-action');
|
||||||
|
|
||||||
|
switch(action) {
|
||||||
|
case 'reload':
|
||||||
|
socket.emit('admin.logs.get', function(err, logs) {
|
||||||
|
if (!err) {
|
||||||
|
logsEl.text(logs);
|
||||||
|
} else {
|
||||||
|
app.alertError(err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'clear':
|
||||||
|
socket.emit('admin.logs.clear', function(err) {
|
||||||
|
if (!err) {
|
||||||
|
app.alertSuccess('Logs Cleared!')
|
||||||
|
btnEl.prev().click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
return Logs;
|
||||||
|
});
|
@ -0,0 +1,28 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
var path = require('path'),
|
||||||
|
fs = require('fs'),
|
||||||
|
winston = require('winston');
|
||||||
|
|
||||||
|
module.exports = function(Meta) {
|
||||||
|
|
||||||
|
Meta.logs = {
|
||||||
|
path: path.join('logs', path.sep, 'output.log')
|
||||||
|
};
|
||||||
|
|
||||||
|
Meta.logs.get = function(callback) {
|
||||||
|
fs.readFile(this.path, {
|
||||||
|
encoding: 'utf-8'
|
||||||
|
}, function(err, logs) {
|
||||||
|
if (err) {
|
||||||
|
winston.error('[meta/logs] Could not retrieve logs: ' + err.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(undefined, logs || '');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Meta.logs.clear = function(callback) {
|
||||||
|
fs.truncate(this.path, 0, callback);
|
||||||
|
}
|
||||||
|
};
|
Loading…
Reference in New Issue