a new oblect utils - enum, enum view, refactoring of mainLayout, debugging, states for sockets

This commit is contained in:
Blue 2018-08-29 22:54:18 +03:00 committed by Gitea
parent fe1b55bb39
commit ca67a8e8bc
14 changed files with 260 additions and 57 deletions

View File

@ -9,7 +9,7 @@ Corax* Corax::corax = 0;
Corax::Corax(QObject *parent): Corax::Corax(QObject *parent):
QObject(parent), QObject(parent),
started(false) started(false),
server(new W::Server(W::String(u"Corax"), this)), server(new W::Server(W::String(u"Corax"), this)),
logger(new W::Logger()), logger(new W::Logger()),
parentReporter(new W::ParentReporter()), parentReporter(new W::ParentReporter()),
@ -262,6 +262,7 @@ void Corax::onNodeConnected(const W::String& name)
cout << "connected node " << name.toString() << endl; cout << "connected node " << name.toString() << endl;
if (name == u"Perturabo") { if (name == u"Perturabo") {
commands->enableCommand(W::String(u"parseDirectory"), true); commands->enableCommand(W::String(u"parseDirectory"), true);
commands->enableCommand(W::String(u"givePlayer"), true);
} }
} }
@ -270,6 +271,7 @@ void Corax::onNodeDisconnected(const W::String& name)
cout << "disconnected node " << name.toString() << endl; cout << "disconnected node " << name.toString() << endl;
if (name == u"Perturabo") { if (name == u"Perturabo") {
commands->enableCommand(W::String(u"parseDirectory"), false); commands->enableCommand(W::String(u"parseDirectory"), false);
commands->enableCommand(W::String(u"givePlayer"), false);
} }
} }
@ -294,6 +296,6 @@ void Corax::h_givePlayer(const W::Event& ev)
W::Event res(source + W::Address{u"getPlayer"}, vc); W::Event res(source + W::Address{u"getPlayer"}, vc);
res.setSenderId(id); res.setSenderId(id);
connector->getConnection(id)->send(ev); connector->getConnection(id)->send(res);
} }

View File

@ -28,17 +28,21 @@ void M::Button::setImage(const W::String& p_image)
if (hasImage) { if (hasImage) {
if (*imageName != p_image) { if (*imageName != p_image) {
imageName = static_cast<W::String*>(p_image.copy()); imageName = static_cast<W::String*>(p_image.copy());
if (registered) {
W::Vocabulary* vc = new W::Vocabulary(); W::Vocabulary* vc = new W::Vocabulary();
vc->insert(u"image", p_image); vc->insert(u"image", p_image);
broadcast(vc, W::Address{u"changeImage"}); broadcast(vc, W::Address{u"changeImage"});
} }
}
} else { } else {
imageName = static_cast<W::String*>(p_image.copy()); imageName = static_cast<W::String*>(p_image.copy());
hasImage = true; hasImage = true;
if (registered) {
W::Vocabulary* vc = new W::Vocabulary(); W::Vocabulary* vc = new W::Vocabulary();
vc->insert(u"image", p_image); vc->insert(u"image", p_image);
broadcast(vc, W::Address{u"setImage"}); broadcast(vc, W::Address{u"setImage"});
} }
}
hasImage = true; hasImage = true;
} }
@ -46,11 +50,13 @@ void M::Button::setEnabled(bool p_enabled)
{ {
if (enabled != p_enabled) { if (enabled != p_enabled) {
enabled = p_enabled; enabled = p_enabled;
if (registered) {
W::Vocabulary* vc = new W::Vocabulary(); W::Vocabulary* vc = new W::Vocabulary();
vc->insert(u"enable", new W::Boolean(enabled)); vc->insert(u"enable", new W::Boolean(enabled));
broadcast(vc, W::Address{u"setEnabled"}); broadcast(vc, W::Address{u"setEnabled"});
} }
} }
}
void M::Button::setLabel(const W::String& p_label) void M::Button::setLabel(const W::String& p_label)
{ {
@ -59,10 +65,12 @@ void M::Button::setLabel(const W::String& p_label)
} else { } else {
label = new M::String(p_label, address + W::Address{u"label"}); label = new M::String(p_label, address + W::Address{u"label"});
addModel(label); addModel(label);
if (registered) {
W::Vocabulary* vc = new W::Vocabulary(); W::Vocabulary* vc = new W::Vocabulary();
vc->insert(u"hasLabel", new W::Boolean(true)); vc->insert(u"hasLabel", new W::Boolean(true));
vc->insert(u"label", label->getAddress()); vc->insert(u"label", label->getAddress());
broadcast(vc, W::Address{u"setLabel"}); broadcast(vc, W::Address{u"setLabel"});
}
hasLabel = true; hasLabel = true;
} }
} }

View File

@ -20,4 +20,4 @@ add_library(wSsh ${HEADERS} ${SOURCES})
target_link_libraries(wSsh Qt5::Core) target_link_libraries(wSsh Qt5::Core)
target_link_libraries(wSsh ssh) target_link_libraries(wSsh ssh)
target_link_libraries(wSsh ssh_threads) #target_link_libraries(wSsh ssh_threads)

View File

@ -3,3 +3,4 @@ cmake_minimum_required(VERSION 2.8.12)
configure_file(class.js class.js) configure_file(class.js class.js)
configure_file(subscribable.js subscribable.js) configure_file(subscribable.js subscribable.js)
configure_file(globalMethods.js globalMethods.js) configure_file(globalMethods.js globalMethods.js)
configure_file(enum.js enum.js)

69
libjs/utils/enum.js Normal file
View File

@ -0,0 +1,69 @@
"use strict";
var Class = require("./class");
var Enum = Class.inherit({
className: "Enum",
constructor: function(name, additional) {
if (typeof name !== "string" || name.length === 0) {
throw new Error("An attempt to register enum with wrong or empty name");
}
if (storage[name]) {
throw new Error("An attempt to register enum " + name + " for the second time");
}
Class.fn.constructor.call(this);
this.name = name;
this.straight = Object.create(null);
this.reversed = Object.create(null);
this.additional = Object.create(null);
this._additionals = additional || [];
this._lastId = 0;
storage[name] = this;
},
add: function(name, additional, id) {
if (typeof name !== "string" || name.length === 0) {
throw new Error("An attempt to add an entry with invalid name to enum " + name);
}
if (!id) {
id = this._lastId + 1;
}
if (this.straight[id] !== undefined) {
throw new Error("Id duplication in enum " + this.name + " during an attempt to add entry " + name);
}
if (this.reversed[name] !== undefined) {
throw new Error("Name duplication in enum " + this.name + " during an attempt to add entry " + name);
}
this.straight[name] = id;
this.reversed[id] = name;
this.additional[id] = Object.create(null);
for (var i = 0; i < this._additionals.length; ++i) {
var key = this._additionals[i];
var aVal = additional[key];
if (aVal === undefined) {
throw new Error("An attempt to add an entry " + name + " into enum " + this.name + " without providing additional value " + key);
}
this.additional[id][key] = aVal;
}
this._lastId = id;
},
hasAdditional: function(name) {
return this._additionals.indexOf(name) !== -1;
}
});
var storage = Object.create(null);
Enum.storage = storage;
module.exports = Enum;

View File

@ -21,6 +21,7 @@ var LocalModel = Subscribable.inherit({
}, },
"setData": function(data) { "setData": function(data) {
this.data = data; this.data = data;
this.initialized = true;
this.trigger("data"); this.trigger("data");
} }
}); });

View File

@ -4,6 +4,7 @@
var defineArray = []; var defineArray = [];
defineArray.push("lib/utils/class"); defineArray.push("lib/utils/class");
defineArray.push("lib/utils/enum");
defineArray.push("lib/wSocket/socket"); defineArray.push("lib/wSocket/socket");
defineArray.push("lib/wDispatcher/dispatcher"); defineArray.push("lib/wDispatcher/dispatcher");
defineArray.push("lib/wDispatcher/handler"); defineArray.push("lib/wDispatcher/handler");
@ -27,6 +28,7 @@
define(moduleName, defineArray, function lorgar_module() { define(moduleName, defineArray, function lorgar_module() {
var Class = require("lib/utils/class"); var Class = require("lib/utils/class");
var Enum = require("lib/utils/enum");
var Socket = require("lib/wSocket/socket"); var Socket = require("lib/wSocket/socket");
var Dispatcher = require("lib/wDispatcher/dispatcher"); var Dispatcher = require("lib/wDispatcher/dispatcher");
var Handler = require("lib/wDispatcher/handler"); var Handler = require("lib/wDispatcher/handler");
@ -53,16 +55,18 @@
"constructor": function() { "constructor": function() {
Class.fn.constructor.call(this); Class.fn.constructor.call(this);
this._playerCtl = undefined;
this._currentPageCtl = undefined; this._currentPageCtl = undefined;
this._nodes = Object.create(null); this._nodes = Object.create(null);
this._initDispatcher(); this._initDispatcher();
this._initModels();
this._initViews();
this._prepareNode("Magnus", "localhost", 8081); this._prepareNode("Magnus", "localhost", 8081);
this._prepareNode("Corax", "localhost", 8080); this._prepareNode("Corax", "localhost", 8080);
this._initModels(); this._registerModels();
this._initViews();
this.connectNode("Magnus"); this.connectNode("Magnus");
this.connectNode("Corax"); this.connectNode("Corax");
@ -70,6 +74,8 @@
}, },
"destructor": function() { "destructor": function() {
window.onpopstate = undefined; window.onpopstate = undefined;
this._unregisterModels();
if (this._currentPageCtl) { if (this._currentPageCtl) {
this._currentPage.destructor(); this._currentPage.destructor();
this._currentPageCtl.destructor(); this._currentPageCtl.destructor();
@ -77,16 +83,17 @@
this._gc.destructor(); this._gc.destructor();
this._ps.destructor(); this._ps.destructor();
this._mainColorHelper.destructor();
this._emptyHelper.destructor(); this._emptyHelper.destructor();
this._body.destructor(); this._body.destructor();
this.coraxSocket.close(); this.coraxSocket.close();
this.dispatcher.unregisterHandler(this._playerResponseHandler);
this.dispatcher.unregisterDefaultHandler(this._logger); this.dispatcher.unregisterDefaultHandler(this._logger);
this._logger.destructor(); this._logger.destructor();
this.dispatcher.destructor(); this.dispatcher.destructor();
this._playerResponseHandler.destructor();
//this.magnusSocket.destructor(); //this.magnusSocket.destructor();
//this.coraxSocket.destructor(); //this.coraxSocket.destructor();
@ -106,31 +113,34 @@
} }
node.socket.open(node.address, node.port); node.socket.open(node.address, node.port);
node.state.setData(SocketState.straight.connecting);
}, },
"_initCoraxSocket": function() { _registerModels: function () {
this.coraxSocket = new Socket("Lorgar"); this._gc.register(this.dispatcher, this._nodes.Magnus.socket);
this.coraxSocket.on("connected", this._coraxSocketConnected, this); this._ps.register(this.dispatcher, this._nodes.Magnus.socket);
this.coraxSocket.on("disconnected", this._coraxSocketDisconnected, this); },
this.coraxSocket.on("error", this._coraxSocketError, this); _unregisterModels: function() {
this.coraxSocket.on("message", this.dispatcher.pass, this.dispatcher); if (this._currentPageCtl) {
this._currentPageCtl.unregister();
}
this._gc.unregister();
this._ps.unregister();
}, },
"_initDispatcher": function() { "_initDispatcher": function() {
this.dispatcher = new Dispatcher(); this.dispatcher = new Dispatcher();
this._logger = new Logger(); this._logger = new Logger();
this._playerResponseHandler = new Handler(new Address(["getPlayer"]), this, this._responsePlayer);
this.dispatcher.registerDefaultHandler(this._logger); this.dispatcher.registerDefaultHandler(this._logger);
this.dispatcher.registerHandler(this._playerResponseHandler);
}, },
"_initModels": function() { "_initModels": function() {
this._gc = new GlobalControls(new Address(["magnus", "gc"])); this._gc = new GlobalControls(new Address(["magnus", "gc"]));
this._ps = new PageStorage(new Address(["magnus", "ps"])); this._ps = new PageStorage(new Address(["magnus", "ps"]));
this._mainColorHelper = new LocalModel({backgroundColor: "mainColor"});
this._emptyHelper = new LocalModel(); this._emptyHelper = new LocalModel();
this._gc.on("themeSelected", this.setTheme, this); this._gc.on("themeSelected", this.setTheme, this);
this._gc.register(this.dispatcher, this._nodes.Magnus.socket);
this._ps.register(this.dispatcher, this._nodes.Magnus.socket);
this._ps.on("pageName", this._onPageName, this); this._ps.on("pageName", this._onPageName, this);
}, },
"_initPageController": function(addr) { "_initPageController": function(addr) {
@ -154,14 +164,6 @@
this._body.setSize(document.body.offsetWidth, document.body.offsetHeight); this._body.setSize(document.body.offsetWidth, document.body.offsetHeight);
this._body.append(this._mainLayout); this._body.append(this._mainLayout);
var spacerL = new View(this._mainColorHelper, {
maxWidth: 50
});
var spacerR = new View(this._mainColorHelper, {
maxWidth: 50
});
this._mainLayout.append(spacerL, 1, 0, 1, 1);
this._mainLayout.append(spacerR, 1, 2, 1, 1);
}, },
"_onHistoryPopState": function(e) { "_onHistoryPopState": function(e) {
this._initPageController(new Address(e.state.address)); this._initPageController(new Address(e.state.address));
@ -175,6 +177,7 @@
console.log(name + " socket connected"); console.log(name + " socket connected");
var node = this._nodes[name]; var node = this._nodes[name];
node.connected = true; node.connected = true;
node.state.setData(SocketState.straight.connected);
for (var id in node.foreigns) { for (var id in node.foreigns) {
if (node.foreigns[id].subscribed) { if (node.foreigns[id].subscribed) {
@ -182,13 +185,18 @@
} }
} }
if (name === "Magnus") { switch (name) {
case "Magnus":
this._gc.subscribe(); this._gc.subscribe();
if (!this._currentPageCtl) { if (!this._currentPageCtl) {
this._ps.getPageAddress(location.pathname); this._ps.getPageAddress(location.pathname);
this._ps.one("pageAddress", this._initPageController, this); this._ps.one("pageAddress", this._initPageController, this);
} }
break;
case "Corax":
this._requestPlayer();
break;
} }
}, },
"_onSocketDisconnected": function(name) { "_onSocketDisconnected": function(name) {
@ -201,8 +209,9 @@
node.foreigns[id].controller._onSocketDisconnected; node.foreigns[id].controller._onSocketDisconnected;
} }
} }
node.state.setData(SocketState.straight.disconnected);
}, },
"_onSocketError": function(name) { "_onSocketError": function(name, e) {
console.log(name + " socket error: "); console.log(name + " socket error: ");
console.log(e); console.log(e);
}, },
@ -220,12 +229,17 @@
obj.socket = new Socket("Lorgar"); obj.socket = new Socket("Lorgar");
obj.connected = false; obj.connected = false;
obj.foreigns = Object.create(null); obj.foreigns = Object.create(null);
obj.state = new LocalModel({fontFamily: "casualFont"});
obj.state.enum = SocketState;
obj.state.setData(SocketState.straight.disconnected);
obj.socket.on("connected", this._onSocketConnected.bind(this, name)); obj.socket.on("connected", this._onSocketConnected.bind(this, name));
obj.socket.on("disconnected", this._onSocketDisconnected.bind(this, name)); obj.socket.on("disconnected", this._onSocketDisconnected.bind(this, name));
obj.socket.on("error", this._onSocketError.bind(this, name)); obj.socket.on("error", this._onSocketError.bind(this, name));
obj.socket.on("message", this.dispatcher.pass, this.dispatcher); obj.socket.on("message", this.dispatcher.pass, this.dispatcher);
this._mainLayout.addState(name, obj.state);
this._nodes[name] = obj; this._nodes[name] = obj;
}, },
"registerForeignController": function(node, controller) { "registerForeignController": function(node, controller) {
@ -243,6 +257,22 @@
node.foreigns[controller.id] = obj; node.foreigns[controller.id] = obj;
controller.register(this.dispatcher, node.socket); controller.register(this.dispatcher, node.socket);
}, },
"_requestPlayer": function() {
var vc = new Vocabulary();
vc.insert("source", new Address([]));
var ev = new Event(new Address(["management", "givePlayer"]), vc);
var socket = this._nodes.Corax.socket;
ev.setSenderId(socket.getId().clone());
socket.send(ev);
ev.destructor();
},
"_responsePlayer": function(ev) {
var data = ev.getData();
console.log('Received player address: ' + data.at("address").toString());
},
"setTheme": function(theme) { "setTheme": function(theme) {
View.setTheme(theme); View.setTheme(theme);
}, },
@ -284,6 +314,11 @@
} }
}); });
var SocketState = new Enum("SocketState", ["description"]);
SocketState.add("disconnected", {description: "Socket is disconnected"});
SocketState.add("connecting", {description: "Socket is connecting to remote host"});
SocketState.add("connected", {description: "Socket is connected"});
return Lorgar; return Lorgar;
}); });
})(); })();

View File

@ -3,3 +3,4 @@ cmake_minimum_required(VERSION 2.8.12)
add_jslib(utils/class.js lib/utils/class ${LORGAR_DIR} browser) add_jslib(utils/class.js lib/utils/class ${LORGAR_DIR} browser)
add_jslib(utils/subscribable.js lib/utils/subscribable ${LORGAR_DIR} browser) add_jslib(utils/subscribable.js lib/utils/subscribable ${LORGAR_DIR} browser)
add_jslib(utils/globalMethods.js lib/utils/globalMethods ${LORGAR_DIR} browser) add_jslib(utils/globalMethods.js lib/utils/globalMethods ${LORGAR_DIR} browser)
add_jslib(utils/enum.js lib/utils/enum ${LORGAR_DIR} browser)

View File

@ -37,7 +37,7 @@
} }
Controller.initialize(["String", "List", "Vocabulary", "Page", "PanesList", "Link", "Image", "Button"], waiter.check.bind(waiter, "controllers")); Controller.initialize(["String", "List", "Vocabulary", "Page", "PanesList", "Link", "Image", "Button"], waiter.check.bind(waiter, "controllers"));
View.initialize(["Label", "Page", "PanesList", "Nav", "Image", "Button"], waiter.check.bind(waiter, "views")); View.initialize(["Label", "Page", "PanesList", "Nav", "Image", "Button", "Enumeration"], waiter.check.bind(waiter, "views"));
var test = new Test(); var test = new Test();
test.run(); test.run();

View File

@ -12,5 +12,6 @@ configure_file(page.js page.js)
configure_file(pane.js pane.js) configure_file(pane.js pane.js)
configure_file(image.js image.js) configure_file(image.js image.js)
configure_file(button.js button.js) configure_file(button.js button.js)
configure_file(enumeration.js enumeration.js)
add_subdirectory(helpers) add_subdirectory(helpers)

View File

@ -0,0 +1,53 @@
"use strict";
(function view_enumeration_js() {
var moduleName = "views/enumeration";
var deps = [];
deps.push("views/gridLayout");
deps.push("views/label");
deps.push("lib/wController/localModel");
define(moduleName, deps, function view_enumeration_module() {
var GridLayout = require("views/gridLayout");
var Label = require("views/label");
var LocalModel = require("lib/wController/localModel");
var Enumeration = GridLayout.inherit({
className: "Enumeration",
constructor: function(controller, options) {
var base = {};
W.extend(base, options)
this._lm = new LocalModel();
GridLayout.fn.constructor.call(this, controller, base);
this._lv = new Label(this._lm);
this.append(this._lv, 0, 0, 1, 1, GridLayout.Aligment.CenterCenter);
this._uncyclic.push(this._lm.destructor.bind(this._lm));
},
_onData: function() {
if (this._f.initialized) {
var e = this._f.enum;
var value = this._f.data;
var title;
if (e.hasAdditional("title")) {
title = e.additional[value].title;
} else {
title = e.reversed[value];
}
var desc = "";
if (e.hasAdditional("description")) {
desc = e.additional[value].description;
}
this._lm.setData(title);
this._e.setAttribute("title", desc);
}
}
});
return Enumeration;
})
})();

View File

@ -5,19 +5,43 @@
var defineArray = []; var defineArray = [];
defineArray.push("views/gridLayout"); defineArray.push("views/gridLayout");
defineArray.push("views/label"); defineArray.push("views/label");
defineArray.push("views/view");
defineArray.push("views/navigationPanel"); defineArray.push("views/navigationPanel");
defineArray.push("views/layout"); defineArray.push("views/layout");
defineArray.push("views/enumeration");
defineArray.push("lib/wController/localModel"); defineArray.push("lib/wController/localModel");
define(moduleName, defineArray, function mainLayout_module() { define(moduleName, defineArray, function mainLayout_module() {
var GridLayout = require("views/gridLayout"); var GridLayout = require("views/gridLayout");
var ViewLabel = require("views/label"); var ViewLabel = require("views/label");
var View = require("views/view");
var ViewNavigationPanel = require("views/navigationPanel"); var ViewNavigationPanel = require("views/navigationPanel");
var Layout = require("views/layout"); var Layout = require("views/layout");
var Enumeration = require("views/enumeration");
var LocalModel = require("lib/wController/localModel"); var LocalModel = require("lib/wController/localModel");
var MainLayout = GridLayout.inherit({ var MainLayout = GridLayout.inherit({
"className": "MainLayout", "className": "MainLayout",
"constructor": function(controller, options) {
GridLayout.fn.constructor.call(this, controller, options);
this._statusBarPosition = 2;
this._mainColorHelper = new LocalModel({backgroundColor: "mainColor"});
this._statusBarModel = new LocalModel({backgroundColor: "secondaryColor"});
this._uncyclic.push(this._statusBarModel.destructor.bind(this._statusBarModel));
this._uncyclic.push(this._mainColorHelper.destructor.bind(this._mainColorHelper));
var spacerL = new View(this._mainColorHelper, {maxWidth: 50});
var spacerR = new View(this._mainColorHelper, {maxWidth: 50});
this.append(spacerL, 1, 0, 1, 1);
this.append(spacerR, 1, 2, 1, 1);
this._statusBar = new GridLayout(this._statusBarModel);
this._statusBar.append(new View(this._statusBarModel), 0, 1, 1, 1);
this.append(this._statusBar, 3, 0, 1, 3);
},
"_onNewController": function(controller) { "_onNewController": function(controller) {
GridLayout.fn._onNewController.call(this, controller); GridLayout.fn._onNewController.call(this, controller);
@ -25,13 +49,8 @@
switch (controller.name) { switch (controller.name) {
case "version": case "version":
var lm = new LocalModel({
backgroundColor: "secondaryColor"
});
var lay = new Layout(lm, {maxHeight: 15})
view = new ViewLabel(controller); view = new ViewLabel(controller);
lay.append(view, Layout.Aligment.RightCenter); this._statusBar.append(view, 0, 0, 1, 1, Layout.Aligment.LeftCenter);
this.append(lay, 2, 0, 1, 3);
break; break;
case "navigationPanel": case "navigationPanel":
view = new ViewNavigationPanel(controller); view = new ViewNavigationPanel(controller);
@ -43,6 +62,16 @@
//this.trigger("serviceMessage", "Unsupported view: " + name + " (" + type + ")", 1); //this.trigger("serviceMessage", "Unsupported view: " + name + " (" + type + ")", 1);
break; break;
} }
},
addState: function(name, state) {
var lm = new LocalModel({fontFamily: "casualFont"});
lm.setData(name + ": ");
var lv = new ViewLabel(lm);
var e = new Enumeration(state);
this._statusBar.append(lv, 0, this._statusBarPosition++, 1, 1, Layout.Aligment.LeftCenter);
this._statusBar.append(e, 0, this._statusBarPosition++, 1, 1, Layout.Aligment.LeftCenter);
this._uncyclic.push(lm.destructor.bind(lm));
} }
}); });

View File

@ -290,6 +290,7 @@
Image: 4, Image: 4,
Button: 5, Button: 5,
View: 6, View: 6,
Enumeration: 7,
Page: 102, Page: 102,
PanesList: 104, PanesList: 104,
@ -302,6 +303,7 @@
"4": "Image", "4": "Image",
"5": "Button", "5": "Button",
"6": "View", "6": "View",
"7": "Enumeration",
"101": "Nav", "101": "Nav",
"102": "Page", "102": "Page",
@ -317,7 +319,8 @@
PanesList: "views/panesList", PanesList: "views/panesList",
Image: "views/image", Image: "views/image",
Button: "views/button", Button: "views/button",
Player: "views/player" Player: "views/player",
Enumeration: "views/enumeration"
}; };
View.constructors = { View.constructors = {

View File

@ -5,7 +5,7 @@ var ENV = config.get('build');
function getLogger(module) { function getLogger(module) {
var path = module.filename.split('/').slice(-2).join('/'); var path = module.filename.split('/').slice(-2).join('/');
return new Winston.Logger({ return Winston.createLogger({
transports: [ transports: [
new Winston.transports.Console({ new Winston.transports.Console({
colorize: true, colorize: true,