10 Commits

Author SHA1 Message Date
8524299d39 1.0.29 2023-01-12 11:58:35 +01:00
227931b0d3 fix(core): update 2023-01-12 11:58:34 +01:00
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
16 changed files with 4468 additions and 11047 deletions

View File

@ -12,30 +12,38 @@ stages:
- release - release
- metadata - metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
mirror: # ====================
stage: security # security stage
script: # ====================
- npmci git mirror auditProductionDependencies:
tags:
- lossless
- docker
- notpriv
audit:
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 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 pnpm audit --audit-level=high --prod
tags: tags:
- lossless - lossless
- docker - 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 # test stage
@ -44,28 +52,22 @@ audit:
testStable: testStable:
stage: test stage: test
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- 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
script: script:
- npmci npm prepare
- npmci node install stable - npmci node install stable
- npmci npm install - npmci npm install
- npmci command npm run build - npmci npm build
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker - docker
- notpriv
release: release:
stage: release stage: release
@ -85,11 +87,12 @@ 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 typescript
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless - lossless
- docker - docker
@ -109,11 +112,9 @@ trigger:
pages: pages:
stage: metadata stage: metadata
script: script:
- npmci node install lts - npmci node install stable
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command npm run buildDocs
tags: tags:
- lossless - lossless
- docker - docker

24
.vscode/launch.json vendored
View File

@ -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"
} }
] ]
} }

View File

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

View File

@ -5,12 +5,13 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",
"gitrepo": "logcontext", "gitrepo": "logcontext",
"shortDescription": "enrich logs with context", "description": "enrich logs with context",
"npmPackagename": "@pushrocks/logcontext", "npmPackagename": "@pushrocks/logcontext",
"license": "MIT" "license": "MIT"
} }
}, },
"npmci": { "npmci": {
"npmAccessLevel": "public",
"npmGlobalTools": [] "npmGlobalTools": []
} }
} }

10932
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{ {
"name": "@pushrocks/logcontext", "name": "@pushrocks/logcontext",
"version": "1.0.24", "version": "1.0.29",
"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)",
"buildDocs": "tsdoc"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.24", "@gitzone/tsbuild": "^2.1.27",
"@gitzone/tsbundle": "^1.0.72", "@gitzone/tsbundle": "^2.0.7",
"@gitzone/tstest": "^1.0.43", "@gitzone/tsrun": "^1.2.39",
"@pushrocks/smartdelay": "^2.0.10", "@gitzone/tstest": "^1.0.57",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/smartdelay": "^2.0.13",
"@types/node": "^14.0.23", "@pushrocks/tapbundle": "^5.0.4",
"tslint": "^6.1.2", "@types/node": "^18.11.18"
"tslint-config-prettier": "^1.18.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/lik": "^4.0.17", "@pushrocks/lik": "^6.0.0",
"@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"
@ -41,5 +41,6 @@
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
] ],
"type": "module"
} }

4372
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](htt
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/logcontext)](https://lossless.cloud) PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/logcontext)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/logcontext)](https://lossless.cloud) PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/logcontext)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/logcontext)](https://lossless.cloud) BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/logcontext)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage ## 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. 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) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,10 +1,10 @@
import { expect, tap } from '@pushrocks/tapbundle'; 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'); 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');
}); });
}); });
}); });
@ -33,8 +33,8 @@ tap.testParallel('should create a new scope', async () => {
}); });
}); });
tap.test('should log within default scope', async (tools) => { tap.test('should log within default scope', async (toolsArg) => {
await tools.delayFor(3000); await toolsArg.delayFor(3000);
testLogger.log('message without context'); testLogger.log('message without context');
}); });

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/logcontext',
version: '1.0.29',
description: 'enrich logs with context'
}

View File

@ -1 +1 @@
export * from './logcontext.classes.logger'; export * from './logcontext.classes.logger.js';

View File

@ -1,12 +1,11 @@
import * as plugins from './logcontext.plugins'; import * as plugins from './logcontext.plugins.js';
import { LogMap } from './logcontext.classes.logmap'; import { LogMap } from './logcontext.classes.logmap.js';
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(),
}; };

View File

@ -1,4 +1,4 @@
import * as plugins from './logcontext.plugins'; import * as plugins from './logcontext.plugins.js';
export class LogMap { export class LogMap {
smartcls: plugins.smartcls.SmartCls; smartcls: plugins.smartcls.SmartCls;
@ -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);
} }

View File

@ -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';

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}

View File

@ -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"
}