Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
e3be31bb93 | |||
3babab347f | |||
765b388889 | |||
80b0bdd663 | |||
185baac511 | |||
2ed9210da9 | |||
7b969943dc | |||
fb8a908a31 | |||
472ca0fcbb | |||
4d47187b1e |
@ -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
24
.vscode/launch.json
vendored
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
||||
"properties": {
|
||||
"projectType": {
|
||||
"type": "string",
|
||||
"enum": ["website", "element", "service", "npm"]
|
||||
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
}
|
||||
},
|
||||
"npmci": {
|
||||
"npmAccessLevel": "public",
|
||||
"npmGlobalTools": []
|
||||
}
|
||||
}
|
21610
package-lock.json
generated
21610
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
20
package.json
20
package.json
@ -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"
|
||||
|
@ -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)
|
||||
|
||||
[](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). :)
|
||||
|
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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(),
|
||||
};
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
// native scope
|
||||
import { AsyncLocalStorage } from 'async_hooks';
|
||||
|
||||
export {
|
||||
AsyncLocalStorage
|
||||
};
|
||||
export { AsyncLocalStorage };
|
||||
|
||||
// pushrocks scope
|
||||
import * as lik from '@pushrocks/lik';
|
||||
|
Reference in New Issue
Block a user