Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
e3be31bb93 | |||
3babab347f | |||
765b388889 | |||
80b0bdd663 | |||
185baac511 | |||
2ed9210da9 | |||
7b969943dc | |||
fb8a908a31 | |||
472ca0fcbb | |||
4d47187b1e |
@ -19,23 +19,36 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- 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
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- 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:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -50,9 +63,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -63,9 +74,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,6 +94,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@ -2,28 +2,10 @@
|
|||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "current file",
|
"command": "npm test",
|
||||||
"type": "node",
|
"name": "Run npm test",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"args": [
|
"type": "node-terminal"
|
||||||
"${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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"npmci": {
|
"npmci": {
|
||||||
|
"npmAccessLevel": "public",
|
||||||
"npmGlobalTools": []
|
"npmGlobalTools": []
|
||||||
}
|
}
|
||||||
}
|
}
|
21572
package-lock.json
generated
21572
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",
|
"name": "@pushrocks/logcontext",
|
||||||
"version": "1.0.23",
|
"version": "1.0.28",
|
||||||
"description": "enrich logs with context",
|
"description": "enrich logs with context",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
@ -8,20 +8,20 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "tsbuild"
|
"build": "(tsbuild --web)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.27",
|
||||||
"@gitzone/tsbundle": "^1.0.72",
|
"@gitzone/tsbundle": "^1.0.87",
|
||||||
"@gitzone/tstest": "^1.0.43",
|
"@gitzone/tstest": "^1.0.57",
|
||||||
"@pushrocks/smartdelay": "^2.0.10",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.0.23",
|
"@types/node": "^16.9.2",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^4.0.17",
|
"@pushrocks/lik": "^4.0.22",
|
||||||
"@pushrocks/smartcls": "^1.0.9",
|
"@pushrocks/smartcls": "^1.0.9",
|
||||||
"@pushrocks/smartunique": "^3.0.3",
|
"@pushrocks/smartunique": "^3.0.3",
|
||||||
"@types/shortid": "0.0.29"
|
"@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
|
## 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). :)
|
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');
|
let testLogger = new logcontext.Logger('testNamespace');
|
||||||
|
|
||||||
tap.test('should log for .error()', async () => {
|
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 () => {
|
tap.test('should log for .fatal()', async () => {
|
||||||
@ -14,12 +14,12 @@ tap.test('should log for .fatal()', async () => {
|
|||||||
// set up independent log context
|
// set up independent log context
|
||||||
tap.testParallel('should create an async LogContext', async (tools) => {
|
tap.testParallel('should create an async LogContext', async (tools) => {
|
||||||
testLogger.scope(async () => {
|
testLogger.scope(async () => {
|
||||||
testLogger.logmap.addData('id1', {
|
testLogger.logmap.addData('paramName1', {
|
||||||
someData: 'someValue',
|
someData: 'someValue',
|
||||||
});
|
});
|
||||||
await tools.delayFor(10).then(async () => {
|
await tools.delayFor(10).then(async () => {
|
||||||
testLogger.log('hi');
|
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';
|
import { LogMap } from './logcontext.classes.logmap';
|
||||||
|
|
||||||
export class Logger {
|
export class Logger {
|
||||||
namespaceString: string;
|
public namespaceString: string;
|
||||||
smartcls: plugins.smartcls.SmartCls;
|
smartcls: plugins.smartcls.SmartCls;
|
||||||
logmap: LogMap;
|
public logmap: LogMap;
|
||||||
thirdPartyLogger: any;
|
public thirdPartyLogger: any;
|
||||||
child: any;
|
|
||||||
settings = {
|
settings = {
|
||||||
enableScope: () => {
|
enableScope: () => {
|
||||||
this.settingsParams.scope = true;
|
this.settingsParams.scope = true;
|
||||||
@ -38,7 +37,7 @@ export class Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addThirdPartyLogger(thirdPartyLoggerArg) {
|
addThirdPartyLogger(thirdPartyLoggerArg: any) {
|
||||||
this.thirdPartyLogger = thirdPartyLoggerArg;
|
this.thirdPartyLogger = thirdPartyLoggerArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +45,7 @@ export class Logger {
|
|||||||
* debug
|
* debug
|
||||||
* @param logMessageArg
|
* @param logMessageArg
|
||||||
*/
|
*/
|
||||||
debug(logMessageArg) {
|
debug(logMessageArg: string) {
|
||||||
this.routeLog('debug', logMessageArg);
|
this.routeLog('debug', logMessageArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -54,16 +53,16 @@ export class Logger {
|
|||||||
* log
|
* log
|
||||||
* @param logMessageArg
|
* @param logMessageArg
|
||||||
*/
|
*/
|
||||||
log(logMessageArg) {
|
log(logMessageArg: string) {
|
||||||
this.routeLog('log', logMessageArg);
|
this.routeLog('log', logMessageArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* info
|
* info
|
||||||
* @param logObjectArg
|
* @param logMessageArg
|
||||||
*/
|
*/
|
||||||
info(logObjectArg) {
|
info(logMessageArg: string) {
|
||||||
this.routeLog('info', logObjectArg);
|
this.routeLog('info', logMessageArg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -71,7 +70,7 @@ export class Logger {
|
|||||||
* @param logMessageArg
|
* @param logMessageArg
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
error(logMessageArg, ...args) {
|
error(logMessageArg: string, ...args: any) {
|
||||||
this.routeLog('error', logMessageArg, ...args);
|
this.routeLog('error', logMessageArg, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,7 +79,7 @@ export class Logger {
|
|||||||
* @param logMessageArg
|
* @param logMessageArg
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
warn(logMessageArg, ...args) {
|
warn(logMessageArg: string, ...args: any) {
|
||||||
this.routeLog('warn', logMessageArg, ...args);
|
this.routeLog('warn', logMessageArg, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ export class Logger {
|
|||||||
* @param logMessageArg
|
* @param logMessageArg
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
fatal(logMessageArg, ...args) {
|
fatal(logMessageArg: string, ...args: any) {
|
||||||
this.routeLog('fatal', logMessageArg, ...args);
|
this.routeLog('fatal', logMessageArg, ...args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,12 +105,12 @@ export class Logger {
|
|||||||
/**
|
/**
|
||||||
* routes the log according to whats available in the environment
|
* routes the log according to whats available in the environment
|
||||||
* @param {string} logMethod
|
* @param {string} logMethod
|
||||||
* @param {any} message
|
* @param {any} messageArg
|
||||||
* @param {any[]} ...args
|
* @param {any[]} ...args
|
||||||
*/
|
*/
|
||||||
private routeLog(logMethod, message, ...args) {
|
private routeLog(logMethod: string, messageArg: string, ...args: any) {
|
||||||
const logObject = {
|
const logObject = {
|
||||||
message: message,
|
message: messageArg,
|
||||||
type: logMethod,
|
type: logMethod,
|
||||||
logContext: this.logmap.getAllData(),
|
logContext: this.logmap.getAllData(),
|
||||||
};
|
};
|
||||||
|
@ -8,7 +8,7 @@ export class LogMap {
|
|||||||
this.smartcls = clsNamespaceArg;
|
this.smartcls = clsNamespaceArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
addData(paramName: string, logData) {
|
addData(paramName: string, logData: any) {
|
||||||
this.paramMap.addString(paramName);
|
this.paramMap.addString(paramName);
|
||||||
this.smartcls.set(paramName, logData);
|
this.smartcls.set(paramName, logData);
|
||||||
}
|
}
|
||||||
@ -22,7 +22,7 @@ export class LogMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getAllData() {
|
getAllData() {
|
||||||
const returnObject = {};
|
const returnObject: any = {};
|
||||||
for (const stringArg of this.paramMap.getStringArray()) {
|
for (const stringArg of this.paramMap.getStringArray()) {
|
||||||
returnObject[stringArg] = this.smartcls.get(stringArg);
|
returnObject[stringArg] = this.smartcls.get(stringArg);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
// native scope
|
// native scope
|
||||||
import { AsyncLocalStorage } from 'async_hooks';
|
import { AsyncLocalStorage } from 'async_hooks';
|
||||||
|
|
||||||
export {
|
export { AsyncLocalStorage };
|
||||||
AsyncLocalStorage
|
|
||||||
};
|
|
||||||
|
|
||||||
// pushrocks scope
|
// pushrocks scope
|
||||||
import * as lik from '@pushrocks/lik';
|
import * as lik from '@pushrocks/lik';
|
||||||
|
Reference in New Issue
Block a user