Compare commits
10 Commits
185baac511
...
3866cb9580
Author | SHA1 | Date | |
---|---|---|---|
3866cb9580 | |||
31140af566 | |||
c4b9833145 | |||
3c6d217563 | |||
8524299d39 | |||
227931b0d3 | |||
e3be31bb93 | |||
3babab347f | |||
765b388889 | |||
80b0bdd663 |
@ -12,30 +12,38 @@ stages:
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- pnpm install -g pnpm
|
||||
- pnpm install -g @shipzone/npmci
|
||||
- npmci npm prepare
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
mirror:
|
||||
stage: security
|
||||
script:
|
||||
- npmci git mirror
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
audit:
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
auditProductionDependencies:
|
||||
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 config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --prod
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
stage: security
|
||||
script:
|
||||
- npmci command npm config set registry https://registry.npmjs.org
|
||||
- npmci command pnpm audit --audit-level=high --dev
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
# ====================
|
||||
# test stage
|
||||
@ -44,28 +52,22 @@ audit:
|
||||
testStable:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- priv
|
||||
|
||||
testBuild:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command npm run build
|
||||
- npmci npm build
|
||||
coverage: /\d+.?\d+?\%\s*coverage/
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
- notpriv
|
||||
|
||||
release:
|
||||
stage: release
|
||||
@ -85,11 +87,12 @@ release:
|
||||
codequality:
|
||||
stage: metadata
|
||||
allow_failure: true
|
||||
only:
|
||||
- tags
|
||||
script:
|
||||
- npmci command npm install -g tslint typescript
|
||||
- npmci command npm install -g typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
@ -109,11 +112,9 @@ trigger:
|
||||
pages:
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci node install lts
|
||||
- npmci command npm install -g @gitzone/tsdoc
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci command tsdoc
|
||||
- npmci command npm run buildDocs
|
||||
tags:
|
||||
- lossless
|
||||
- docker
|
||||
|
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
"projectType": "npm",
|
||||
"module": {
|
||||
"githost": "gitlab.com",
|
||||
"gitscope": "pushrocks",
|
||||
"gitscope": "push.rocks",
|
||||
"gitrepo": "logcontext",
|
||||
"shortDescription": "enrich logs with context",
|
||||
"npmPackagename": "@pushrocks/logcontext",
|
||||
"description": "enrich logs with context",
|
||||
"npmPackagename": "@push.rocks/logcontext",
|
||||
"license": "MIT"
|
||||
}
|
||||
},
|
||||
|
10932
package-lock.json
generated
10932
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
29
package.json
29
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/logcontext",
|
||||
"version": "1.0.26",
|
||||
"name": "@push.rocks/logcontext",
|
||||
"version": "2.0.0",
|
||||
"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 --web)"
|
||||
"build": "(tsbuild --web)",
|
||||
"buildDocs": "tsdoc"
|
||||
},
|
||||
"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",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
"@gitzone/tsbuild": "^2.1.27",
|
||||
"@gitzone/tsbundle": "^2.0.7",
|
||||
"@gitzone/tsrun": "^1.2.39",
|
||||
"@gitzone/tstest": "^1.0.57",
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/tapbundle": "^5.0.4",
|
||||
"@types/node": "^18.11.18"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/lik": "^4.0.17",
|
||||
"@pushrocks/lik": "^6.0.0",
|
||||
"@pushrocks/smartcls": "^1.0.9",
|
||||
"@pushrocks/smartunique": "^3.0.3",
|
||||
"@types/shortid": "0.0.29"
|
||||
@ -41,5 +41,6 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
]
|
||||
}
|
||||
],
|
||||
"type": "module"
|
||||
}
|
4385
pnpm-lock.yaml
generated
Normal file
4385
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,6 @@ Code Style | [](htt
|
||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||
|
||||
## Usage
|
||||
|
||||
@ -78,7 +77,6 @@ We are always happy for code contributions. If you are not the code contributing
|
||||
|
||||
For further information read the linked docs at the top of this readme.
|
||||
|
||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||
## Legal
|
||||
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
|
||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
||||
|
||||
[](https://maintainedby.lossless.com)
|
||||
|
12
test/test.ts
12
test/test.ts
@ -1,10 +1,10 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as logcontext from '../ts/index';
|
||||
import * as logcontext from '../ts/index.js';
|
||||
|
||||
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');
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -33,8 +33,8 @@ tap.testParallel('should create a new scope', async () => {
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should log within default scope', async (tools) => {
|
||||
await tools.delayFor(3000);
|
||||
tap.test('should log within default scope', async (toolsArg) => {
|
||||
await toolsArg.delayFor(3000);
|
||||
testLogger.log('message without context');
|
||||
});
|
||||
|
||||
|
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/logcontext',
|
||||
version: '2.0.0',
|
||||
description: 'enrich logs with context'
|
||||
}
|
@ -1 +1 @@
|
||||
export * from './logcontext.classes.logger';
|
||||
export * from './logcontext.classes.logger.js';
|
||||
|
@ -1,12 +1,11 @@
|
||||
import * as plugins from './logcontext.plugins';
|
||||
import { LogMap } from './logcontext.classes.logmap';
|
||||
import * as plugins from './logcontext.plugins.js';
|
||||
import { LogMap } from './logcontext.classes.logmap.js';
|
||||
|
||||
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(),
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import * as plugins from './logcontext.plugins';
|
||||
import * as plugins from './logcontext.plugins.js';
|
||||
|
||||
export class LogMap {
|
||||
smartcls: plugins.smartcls.SmartCls;
|
||||
@ -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';
|
||||
|
10
tsconfig.json
Normal file
10
tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"moduleResolution": "nodenext",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
17
tslint.json
17
tslint.json
@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user