10 Commits

Author SHA1 Message Date
e3be31bb93 1.0.28 2021-09-17 19:34:27 +02:00
3babab347f fix(core): update 2021-09-17 19:34:27 +02:00
765b388889 1.0.27 2021-09-17 19:21:35 +02:00
80b0bdd663 fix(core): update 2021-09-17 19:21:34 +02:00
185baac511 1.0.26 2020-07-20 19:55:01 +00:00
2ed9210da9 fix(core): update 2020-07-20 19:55:01 +00:00
7b969943dc 1.0.25 2020-07-20 19:51:10 +00:00
fb8a908a31 fix(core): update 2020-07-20 19:51:09 +00:00
472ca0fcbb 1.0.24 2020-07-20 12:32:14 +00:00
4d47187b1e fix(core): update 2020-07-20 12:32:13 +00:00
11 changed files with 18882 additions and 2855 deletions

View File

@ -19,23 +19,36 @@ mirror:
stage: security
script:
- npmci git mirror
only:
- tags
tags:
- lossless
- docker
- notpriv
audit:
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --production --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high --only=prod --production
tags:
- docker
allow_failure: true
auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install --ignore-scripts
- npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
- npmci command npm audit --audit-level=high --only=dev
tags:
- lossless
- docker
- notpriv
allow_failure: true
# ====================
# test stage
@ -50,9 +63,7 @@ testStable:
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- priv
testBuild:
stage: test
@ -63,9 +74,7 @@ testBuild:
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- lossless
- docker
- notpriv
release:
stage: release
@ -85,6 +94,8 @@ release:
codequality:
stage: metadata
allow_failure: true
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci npm prepare

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
"type": "node-terminal"
}
]
}

View File

@ -15,7 +15,7 @@
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm"]
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}

View File

@ -11,6 +11,7 @@
}
},
"npmci": {
"npmAccessLevel": "public",
"npmGlobalTools": []
}
}

21572
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/logcontext",
"version": "1.0.23",
"version": "1.0.28",
"description": "enrich logs with context",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
@ -8,20 +8,20 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "tsbuild"
"build": "(tsbuild --web)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.24",
"@gitzone/tsbundle": "^1.0.72",
"@gitzone/tstest": "^1.0.43",
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.0.23",
"tslint": "^6.1.2",
"@gitzone/tsbuild": "^2.1.27",
"@gitzone/tsbundle": "^1.0.87",
"@gitzone/tstest": "^1.0.57",
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/tapbundle": "^3.2.14",
"@types/node": "^16.9.2",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0"
},
"dependencies": {
"@pushrocks/lik": "^4.0.17",
"@pushrocks/lik": "^4.0.22",
"@pushrocks/smartcls": "^1.0.9",
"@pushrocks/smartunique": "^3.0.3",
"@types/shortid": "0.0.29"

View File

@ -72,14 +72,6 @@ myLogger.scope(async () => {
});
```
For further information read the linked docs at the top of this README.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)

View File

@ -4,7 +4,7 @@ import * as logcontext from '../ts/index';
let testLogger = new logcontext.Logger('testNamespace');
tap.test('should log for .error()', async () => {
testLogger.error(new Error('first error message'));
testLogger.error('first error message');
});
tap.test('should log for .fatal()', async () => {
@ -14,12 +14,12 @@ tap.test('should log for .fatal()', async () => {
// set up independent log context
tap.testParallel('should create an async LogContext', async (tools) => {
testLogger.scope(async () => {
testLogger.logmap.addData('id1', {
testLogger.logmap.addData('paramName1', {
someData: 'someValue',
});
await tools.delayFor(10).then(async () => {
testLogger.log('hi');
testLogger.error(new Error('custom error message'));
testLogger.error('custom error message');
});
});
});

View File

@ -2,11 +2,10 @@ import * as plugins from './logcontext.plugins';
import { LogMap } from './logcontext.classes.logmap';
export class Logger {
namespaceString: string;
public namespaceString: string;
smartcls: plugins.smartcls.SmartCls;
logmap: LogMap;
thirdPartyLogger: any;
child: any;
public logmap: LogMap;
public thirdPartyLogger: any;
settings = {
enableScope: () => {
this.settingsParams.scope = true;
@ -38,7 +37,7 @@ export class Logger {
}
}
addThirdPartyLogger(thirdPartyLoggerArg) {
addThirdPartyLogger(thirdPartyLoggerArg: any) {
this.thirdPartyLogger = thirdPartyLoggerArg;
}
@ -46,7 +45,7 @@ export class Logger {
* debug
* @param logMessageArg
*/
debug(logMessageArg) {
debug(logMessageArg: string) {
this.routeLog('debug', logMessageArg);
}
@ -54,16 +53,16 @@ export class Logger {
* log
* @param logMessageArg
*/
log(logMessageArg) {
log(logMessageArg: string) {
this.routeLog('log', logMessageArg);
}
/**
* info
* @param logObjectArg
* @param logMessageArg
*/
info(logObjectArg) {
this.routeLog('info', logObjectArg);
info(logMessageArg: string) {
this.routeLog('info', logMessageArg);
}
/**
@ -71,7 +70,7 @@ export class Logger {
* @param logMessageArg
* @param args
*/
error(logMessageArg, ...args) {
error(logMessageArg: string, ...args: any) {
this.routeLog('error', logMessageArg, ...args);
}
@ -80,7 +79,7 @@ export class Logger {
* @param logMessageArg
* @param args
*/
warn(logMessageArg, ...args) {
warn(logMessageArg: string, ...args: any) {
this.routeLog('warn', logMessageArg, ...args);
}
@ -89,7 +88,7 @@ export class Logger {
* @param logMessageArg
* @param args
*/
fatal(logMessageArg, ...args) {
fatal(logMessageArg: string, ...args: any) {
this.routeLog('fatal', logMessageArg, ...args);
}
@ -106,12 +105,12 @@ export class Logger {
/**
* routes the log according to whats available in the environment
* @param {string} logMethod
* @param {any} message
* @param {any} messageArg
* @param {any[]} ...args
*/
private routeLog(logMethod, message, ...args) {
private routeLog(logMethod: string, messageArg: string, ...args: any) {
const logObject = {
message: message,
message: messageArg,
type: logMethod,
logContext: this.logmap.getAllData(),
};

View File

@ -8,7 +8,7 @@ export class LogMap {
this.smartcls = clsNamespaceArg;
}
addData(paramName: string, logData) {
addData(paramName: string, logData: any) {
this.paramMap.addString(paramName);
this.smartcls.set(paramName, logData);
}
@ -22,7 +22,7 @@ export class LogMap {
}
getAllData() {
const returnObject = {};
const returnObject: any = {};
for (const stringArg of this.paramMap.getStringArray()) {
returnObject[stringArg] = this.smartcls.get(stringArg);
}

View File

@ -1,9 +1,7 @@
// native scope
import { AsyncLocalStorage } from 'async_hooks';
export {
AsyncLocalStorage
};
export { AsyncLocalStorage };
// pushrocks scope
import * as lik from '@pushrocks/lik';