Add callback to log function. Fix logging

pull/284/head
Tim Robinson 2016-03-23 19:02:05 +00:00
rodzic 5195df553e
commit ffca6961fd
3 zmienionych plików z 11 dodań i 5 usunięć

Wyświetl plik

@ -109,6 +109,7 @@ module.exports = function(options) {
// VFS
"plugins/c9.vfs.client/vfs.ping",
"plugins/c9.vfs.client/vfs.log",
{
packagePath: "plugins/c9.vfs.client/vfs_client",
debug: debug,

Wyświetl plik

@ -1,9 +1,9 @@
module.exports = function(vfs, options, register) {
register(null, {
log: function(message, callback) {
console.log("VFSLOG: " + message);
console.error("VFSERROR: " + message);
log: function (message, callback) {
callback = callback || function(){};
console.log(message);
callback();
}
})

Wyświetl plik

@ -44,8 +44,13 @@ define(function (require, exports, module) {
function log() {
if (!server) return console.error("Cannot log, client is offline");
var callback = function(){};
var args = Array.prototype.slice.call(arguments);
if (typeof args[args.length-1] === "function") {
callback = args.splice(args.length-1, 1);
}
var message = "";
args.forEach(function (arg) {
if (typeof arg === "object") {
@ -54,7 +59,7 @@ define(function (require, exports, module) {
message += arg;
});
server.log(message);
server.log(message, callback);
}
plugin.on("load", function() {