fix(core): update

This commit is contained in:
2020-07-20 11:57:20 +00:00
parent cfe8a5f81a
commit a5dabd17cc
14 changed files with 11216 additions and 471 deletions

View File

@ -3,7 +3,7 @@ import { LogMap } from './logcontext.classes.logmap';
export class Logger {
namespaceString: string;
clsNameSpace: plugins.smartcls.Namespace;
smartcls: plugins.smartcls.SmartCls;
logmap: LogMap;
thirdPartyLogger: any;
child: any;
@ -19,17 +19,17 @@ export class Logger {
},
disableAddData: () => {
this.settingsParams.addData = false;
}
},
};
private settingsParams: { scope: boolean; addData: boolean } = {
scope: true,
addData: true
addData: true,
};
constructor(namespaceArg: string = plugins.shortid()) {
constructor(namespaceArg: string = plugins.smartunique.shortId()) {
this.namespaceString = namespaceArg;
this.clsNameSpace = plugins.smartcls.createNamespace(this.namespaceString);
this.logmap = new LogMap(this.clsNameSpace);
this.smartcls = new plugins.smartcls.SmartCls();
this.logmap = new LogMap(this.smartcls);
}
addData(paramNameArg: string, dataArg: any) {
@ -97,7 +97,7 @@ export class Logger {
scope(funcArg: any) {
// create node continuation scope
if (this.settingsParams.scope) {
this.clsNameSpace.run(funcArg);
this.smartcls.run(funcArg);
} else {
funcArg();
}
@ -110,10 +110,10 @@ export class Logger {
* @param {any[]} ...args
*/
private routeLog(logMethod, message, ...args) {
let logObject = {
const logObject = {
message: message,
type: logMethod,
logContext: this.logmap.getAllData()
logContext: this.logmap.getAllData(),
};
if (this.thirdPartyLogger && this.thirdPartyLogger[logMethod]) {
this.thirdPartyLogger[logMethod](logObject, ...args);

View File

@ -1,33 +1,30 @@
import * as plugins from './logcontext.plugins';
import { Namespace } from 'smartcls';
import { Stringmap } from 'lik';
export class LogMap {
clsNamespace: Namespace;
smartcls: plugins.smartcls.SmartCls;
paramMap = new plugins.lik.Stringmap();
constructor(clsNamespaceArg: Namespace) {
this.clsNamespace = clsNamespaceArg;
constructor(clsNamespaceArg: plugins.smartcls.SmartCls) {
this.smartcls = clsNamespaceArg;
}
addData(paramName: string, logData) {
this.paramMap.addString(paramName);
this.clsNamespace.set(paramName, logData);
this.smartcls.set(paramName, logData);
}
deleteData(paramName: string) {
this.clsNamespace.set(paramName, null);
this.smartcls.set(paramName, null);
}
getData(paramName: string) {
return this.clsNamespace.get(paramName);
return this.smartcls.get(paramName);
}
getAllData() {
let returnObject = {};
for (let stringArg of this.paramMap.getStringArray()) {
returnObject[stringArg] = this.clsNamespace.get(stringArg);
const returnObject = {};
for (const stringArg of this.paramMap.getStringArray()) {
returnObject[stringArg] = this.smartcls.get(stringArg);
}
return returnObject;
}

View File

@ -1,7 +1,13 @@
import 'typings-global';
// native scope
import { AsyncLocalStorage } from 'async_hooks';
import * as lik from 'lik';
import * as smartcls from 'smartcls';
import * as shortid from 'shortid';
export {
AsyncLocalStorage
};
export { lik, smartcls, shortid };
// pushrocks scope
import * as lik from '@pushrocks/lik';
import * as smartcls from '@pushrocks/smartcls';
import * as smartunique from '@pushrocks/smartunique';
export { lik, smartcls, smartunique };