Adding loggers

This commit is contained in:
Martin Karkowski 2021-10-18 08:00:35 +02:00
parent 666936f719
commit 596bdcd7c8
2 changed files with 13 additions and 1 deletions

View File

@ -6,6 +6,7 @@
* @desc [description]
*/
import { ILogger } from "js-logger";
import {
getMethodPath,
getPropertyPath,
@ -13,6 +14,7 @@ import {
isPropertyPathCorrect
} from "../helpers/dispatcherPathes";
import { deepClone } from "../helpers/objectMethods";
import { getNopeLogger } from "../logger/getLogger";
import { INopeDispatcher } from "../types/nope/nopeDispatcher.interface";
import {
IAuthor,
@ -130,6 +132,8 @@ export class NopeBaseModule implements INopeModule {
type: "method" | "prop";
}>;
protected _logger: ILogger
/**
* Creates an instance of BaseModule.
* @memberof BaseModule
@ -142,6 +146,7 @@ export class NopeBaseModule implements INopeModule {
this._registeredFunctions = new Map();
this._registeredProperties = new Map();
this.uiLinks = [];
this._logger = getNopeLogger("BaseModule");
}
public uiLinks: { name: string; description: string; link: string }[];

View File

@ -7,6 +7,7 @@
*/
import { deepClone } from "../helpers/objectMethods";
import { getNopeLogger } from "../logger/getLogger";
import { ICallOptions } from "../types/nope/nopeCommunication.interface";
import { INopeDispatcher } from "../types/nope/nopeDispatcher.interface";
import {
@ -105,9 +106,13 @@ export class NopeGenericModule extends NopeBaseModule {
if (this.identifier == null) {
this.identifier = description.identifier;
this._logger = getNopeLogger("generic-wrapper-" + this.identifier, "debug");
}
for (const name in description.functions) {
this._logger.debug("Create function interface for \"" + name + "\"");
const options = description.functions[name];
const func = (...args) => {
return _this._dispatcher.performCall(options.id, args, options);
@ -142,7 +147,6 @@ export class NopeGenericModule extends NopeBaseModule {
}
this[name] = func;
}
this._registeredFunctions.set(name, {
func,
options
@ -150,6 +154,8 @@ export class NopeGenericModule extends NopeBaseModule {
}
for (const name in description.properties) {
this._logger.debug("Create property interface for \"" + name + "\"");
const options = description.properties[name];
// Add only elements, that are subscribed.
@ -186,6 +192,7 @@ export class NopeGenericModule extends NopeBaseModule {
this[name] = this.dynamicInstanceProperties[name];
}
this._logger.debug("Register Property \"" + name + "\"", options);
this._registeredProperties.set(name, {
observable: this.dynamicInstanceProperties[name],
options