Compare commits

...

10 Commits

Author SHA1 Message Date
3866cb9580 switch to new org scheme 2023-07-11 00:01:09 +02:00
31140af566 switch to new org scheme 2023-07-10 02:41:36 +02:00
c4b9833145 2.0.0 2023-01-12 11:59:41 +01:00
3c6d217563 BREAKING CHANGE(switch to esm): update 2023-01-12 11:59:41 +01:00
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
16 changed files with 4484 additions and 11051 deletions

View File

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

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

File diff suppressed because it is too large Load Diff

View File

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

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 (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)
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
@ -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)
[![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 * 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
View 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'
}

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 { 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(),
};

View File

@ -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);
}

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

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