Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
13981404f3 | |||
db951d1877 | |||
26c84b3a04 | |||
b3d8cf68f1 | |||
60ae0fed4e | |||
a03e821c02 | |||
592178f066 | |||
260af690ff | |||
7bd12e7a01 | |||
f8a49e033d | |||
3066503a70 | |||
cf899609be |
@ -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
|
||||
|
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"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
25592
package-lock.json
generated
25592
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
21
package.json
21
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartlog",
|
||||
"version": "2.0.35",
|
||||
"version": "2.0.41",
|
||||
"private": false,
|
||||
"description": "minimalistic distributed and extensible logging tool",
|
||||
"keywords": [
|
||||
@ -21,18 +21,18 @@
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.24",
|
||||
"@gitzone/tsrun": "^1.2.12",
|
||||
"@gitzone/tstest": "^1.0.33",
|
||||
"@pushrocks/tapbundle": "^3.2.1",
|
||||
"@types/node": "^14.0.13",
|
||||
"tslint": "^6.1.2",
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^1.0.80",
|
||||
"@gitzone/tsrun": "^1.2.17",
|
||||
"@gitzone/tstest": "^1.0.54",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^16.0.0",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.18.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gitzone/tsbundle": "^1.0.69",
|
||||
"@pushrocks/isounique": "^1.0.4",
|
||||
"@pushrocks/smartlog-interfaces": "^2.0.20"
|
||||
"@pushrocks/smartlog-interfaces": "^2.0.22"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
@ -45,5 +45,8 @@
|
||||
"cli.js",
|
||||
"npmextra.json",
|
||||
"readme.md"
|
||||
],
|
||||
"browserslist": [
|
||||
"last 1 chrome versions"
|
||||
]
|
||||
}
|
||||
|
48
test/test.browser.ts
Normal file
48
test/test.browser.ts
Normal file
@ -0,0 +1,48 @@
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartlog from '../ts/index';
|
||||
|
||||
let testConsoleLog: smartlog.ConsoleLog;
|
||||
let testSmartLog: smartlog.Smartlog;
|
||||
|
||||
tap.test('should produce a valid ConsoleLog instance', async () => {
|
||||
testConsoleLog = new smartlog.ConsoleLog();
|
||||
testConsoleLog.log('ok', 'this is ok');
|
||||
});
|
||||
|
||||
tap.test('should produce instance of Smartlog', async () => {
|
||||
testSmartLog = new smartlog.Smartlog({
|
||||
logContext: {
|
||||
environment: 'test',
|
||||
runtime: 'node',
|
||||
zone: 'gitzone',
|
||||
company: 'Lossless GmbH',
|
||||
companyunit: 'Lossless Cloud',
|
||||
containerName: 'testing',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should enable console logging', async () => {
|
||||
testSmartLog.enableConsole({
|
||||
captureAll: true,
|
||||
});
|
||||
console.log('this is a normal log that should be captured');
|
||||
console.log(new Error('hi there'));
|
||||
testSmartLog.log('info', 'this should only be printed once');
|
||||
});
|
||||
|
||||
tap.test('should be able to log things', async () => {
|
||||
testSmartLog.log('silly', 'hi');
|
||||
});
|
||||
|
||||
tap.test('should create a log group', async () => {
|
||||
const logGroup = testSmartLog.createLogGroup('some cool transaction');
|
||||
logGroup.log('info', 'this is logged from a log group');
|
||||
});
|
||||
|
||||
tap.test('should catch error', async () => {
|
||||
console.error(new Error('hey'));
|
||||
// throw new Error('hey');
|
||||
});
|
||||
|
||||
tap.start();
|
@ -17,14 +17,14 @@ tap.test('should produce instance of Smartlog', async () => {
|
||||
zone: 'gitzone',
|
||||
company: 'Lossless GmbH',
|
||||
companyunit: 'Lossless Cloud',
|
||||
containerName: 'testing'
|
||||
}
|
||||
containerName: 'testing',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should enable console logging', async () => {
|
||||
testSmartLog.enableConsole({
|
||||
captureAll: true
|
||||
captureAll: true,
|
||||
});
|
||||
console.log('this is a normal log that should be captured');
|
||||
console.log(new Error('hi there'));
|
||||
|
@ -21,7 +21,7 @@ export class LogGroup {
|
||||
type: 'none',
|
||||
group: this.groupId,
|
||||
instance: this.smartlogRef.uniInstanceId,
|
||||
transaction: this.transactionId
|
||||
transaction: this.transactionId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -35,16 +35,16 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
||||
* enables console logging
|
||||
*/
|
||||
public enableConsole(optionsArg?: { captureAll: boolean }) {
|
||||
if (process && optionsArg && optionsArg.captureAll) {
|
||||
if (globalThis.process && optionsArg && optionsArg.captureAll) {
|
||||
const process = globalThis.process;
|
||||
const write = process.stdout.write;
|
||||
/* import * as fs from 'fs';
|
||||
const fileStream = fs.createWriteStream(plugins.path.join(paths.nogitDir, 'output.txt'), {
|
||||
flags: 'a+'
|
||||
}); */
|
||||
process.stdout.write = (...args) => {
|
||||
process.stdout.write = (...args: any) => {
|
||||
const logString: string = args[0];
|
||||
if (!logString) {
|
||||
return;
|
||||
}
|
||||
if (!logString.startsWith('LOG') && typeof logString === 'string') {
|
||||
switch(true) {
|
||||
switch (true) {
|
||||
case logString.substr(0, 20).includes('Error:'):
|
||||
this.log('error', logString);
|
||||
break;
|
||||
@ -58,7 +58,7 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
||||
return true;
|
||||
};
|
||||
|
||||
process.stderr.write = (...args) => {
|
||||
process.stderr.write = (...args: any) => {
|
||||
if (!args[0].startsWith('LOG')) {
|
||||
this.log('error', args[0]);
|
||||
return;
|
||||
@ -91,9 +91,9 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
||||
...{
|
||||
id: plugins.isounique.uni(),
|
||||
type: 'none',
|
||||
instance: this.uniInstanceId
|
||||
instance: this.uniInstanceId,
|
||||
},
|
||||
...correlationArg
|
||||
...correlationArg,
|
||||
};
|
||||
|
||||
if (this.consoleEnabled) {
|
||||
@ -106,7 +106,7 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
||||
context: this.logContext,
|
||||
level: logLevelArg,
|
||||
correlation: correlationArg,
|
||||
message: logMessageArg
|
||||
message: logMessageArg,
|
||||
};
|
||||
if (logDataArg) {
|
||||
logPackage.data = logDataArg;
|
||||
@ -120,7 +120,7 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
||||
logDataArg?: any,
|
||||
correlationArg: plugins.smartlogInterfaces.ILogCorrelation = {
|
||||
id: plugins.isounique.uni(),
|
||||
type: 'none'
|
||||
type: 'none',
|
||||
}
|
||||
) {
|
||||
if (this.consoleEnabled) {
|
||||
@ -132,7 +132,7 @@ export class Smartlog implements plugins.smartlogInterfaces.ILogDestination {
|
||||
context: this.logContext,
|
||||
level: logLevelArg,
|
||||
message: logMessageArg,
|
||||
correlation: correlationArg
|
||||
correlation: correlationArg,
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user