Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
f2c0f1acff | |||
5805cc51a6 | |||
c9c38368c1 | |||
640eddae2d | |||
ade4d86597 | |||
d4cc9dbcd0 | |||
cde3686209 | |||
485e04c0b3 | |||
0ee2b8295a | |||
4fd4de20c2 | |||
accf03f1b4 | |||
8e8e2c7bd6 |
@ -26,6 +26,7 @@ mirror:
|
|||||||
snyk:
|
snyk:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
- npmci command npm install -g snyk
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command snyk test
|
||||||
@ -39,6 +40,7 @@ snyk:
|
|||||||
testLEGACY:
|
testLEGACY:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install legacy
|
- npmci node install legacy
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -51,6 +53,7 @@ testLEGACY:
|
|||||||
testLTS:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -62,6 +65,7 @@ testLTS:
|
|||||||
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
|
||||||
@ -117,8 +121,10 @@ pages:
|
|||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g npmpage
|
- npmci command npm install -g typedoc typescript
|
||||||
- npmci command npmpage
|
- npmci npm prepare
|
||||||
|
- npmci npm install
|
||||||
|
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
@ -128,3 +134,14 @@ pages:
|
|||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
allow_failure: true
|
||||||
|
|
||||||
|
windowsCompatibility:
|
||||||
|
image: stefanscherer/node-windows:10-build-tools
|
||||||
|
stage: metadata
|
||||||
|
script:
|
||||||
|
- npm install & npm test
|
||||||
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
|
tags:
|
||||||
|
- windows
|
||||||
|
allow_failure: true
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [
|
"npmGlobalTools": [],
|
||||||
"npmts"
|
|
||||||
],
|
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1123
package-lock.json
generated
1123
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
18
package.json
18
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartlog",
|
"name": "@pushrocks/smartlog",
|
||||||
"version": "1.0.5",
|
"version": "2.0.4",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "winston based logger for large scale projects",
|
"description": "winston based logger for large scale projects",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -8,16 +8,20 @@
|
|||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tsrun test/test.ts)",
|
"test": "(tstest test/)",
|
||||||
"build": "echo \"Not needed for now\"",
|
"build": "(tsbuild)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsrun": "^1.0.4",
|
"@gitzone/tsbuild": "^2.0.22",
|
||||||
"cz-conventional-changelog": "^2.1.0",
|
"@gitzone/tsrun": "^1.1.13",
|
||||||
"tapbundle": "^1.0.13"
|
"@gitzone/tstest": "^1.0.15",
|
||||||
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
|
"@types/node": "^10.12.2",
|
||||||
|
"tslint": "^5.11.0",
|
||||||
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"smartlog-interfaces": "^1.0.4"
|
"@pushrocks/smartlog-interfaces": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import { expect, tap } from 'tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartlog from '../ts/index';
|
import * as smartlog from '../ts/index';
|
||||||
|
|
||||||
let defaultLogger: smartlog.Smartlog;
|
let defaultLogger: smartlog.Smartlog;
|
||||||
|
|
||||||
tap.test('should produce instance of Smartlog', async () => {
|
tap.test('should produce instance of Smartlog', async () => {
|
||||||
defaultLogger = smartlog.getDefaultLogger();
|
defaultLogger = smartlog.defaultLogger;
|
||||||
expect(defaultLogger).to.be.instanceOf(smartlog.Smartlog);
|
expect(defaultLogger).to.be.instanceOf(smartlog.Smartlog);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
21
ts/index.ts
21
ts/index.ts
@ -1,13 +1,14 @@
|
|||||||
import * as plugins from './smartlog.plugins';
|
import * as plugins from './smartlog.plugins';
|
||||||
import { Smartlog } from './smartlog.classes.smartlog';
|
import { Smartlog } from './smartlog.classes.smartlog';
|
||||||
|
const defaultLogger: Smartlog = new Smartlog({
|
||||||
export { Smartlog };
|
logContext: {
|
||||||
|
company: 'undefined',
|
||||||
let defaultLogger: Smartlog;
|
companyunit: 'undefefined',
|
||||||
|
containerName: 'undefined',
|
||||||
export const getDefaultLogger = () => {
|
environment: 'local',
|
||||||
if (!defaultLogger) {
|
runtime: 'node',
|
||||||
defaultLogger = new Smartlog();
|
zone: 'undefined'
|
||||||
}
|
}
|
||||||
return defaultLogger;
|
});
|
||||||
};
|
|
||||||
|
export { Smartlog, defaultLogger };
|
||||||
|
@ -1,10 +1,23 @@
|
|||||||
import * as plugins from './smartlog.plugins';
|
import * as plugins from './smartlog.plugins';
|
||||||
|
|
||||||
import { ILogDestination } from 'smartlog-interfaces';
|
import { ILogDestination, ILogPackage } from '@pushrocks/smartlog-interfaces';
|
||||||
|
|
||||||
export class LogRouter {
|
export class LogRouter {
|
||||||
logDestinations: ILogDestination[] = [];
|
/**
|
||||||
|
* all log destinations
|
||||||
|
*/
|
||||||
|
private logDestinations: ILogDestination[] = [];
|
||||||
|
|
||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
addLogDestination;
|
public addLogDestination(logDestination: ILogDestination) {
|
||||||
|
this.logDestinations.push(logDestination);
|
||||||
|
}
|
||||||
|
|
||||||
|
// routes the log according to added logDestinations
|
||||||
|
routeLog(logPackageArg: ILogPackage) {
|
||||||
|
for (const logDestination of this.logDestinations) {
|
||||||
|
logDestination.handleLog(logPackageArg);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,31 @@
|
|||||||
import * as plugins from './smartlog.plugins';
|
import * as plugins from './smartlog.plugins';
|
||||||
|
|
||||||
// interfaces
|
// interfaces
|
||||||
import { TEnvironment, ILogContext, TLogLevel, TRuntime } from 'smartlog-interfaces';
|
import { TLogType, TEnvironment, ILogContext, TLogLevel, TRuntime } from '@pushrocks/smartlog-interfaces';
|
||||||
|
|
||||||
|
import { LogRouter } from './smartlog.classes.logrouter';
|
||||||
|
|
||||||
|
export interface ISmartlogContructorOptions {
|
||||||
|
logContext: ILogContext;
|
||||||
|
minimumLogLevel?: TLogLevel;
|
||||||
|
}
|
||||||
|
|
||||||
export class Smartlog {
|
export class Smartlog {
|
||||||
private logContext: ILogContext;
|
private logContext: ILogContext;
|
||||||
|
private minimumLogLevel: TLogLevel;
|
||||||
|
|
||||||
private consoleEnabled: boolean;
|
private consoleEnabled: boolean;
|
||||||
private minimumLevel: TLogLevel;
|
|
||||||
private runtime: TRuntime;
|
public logRouter = new LogRouter();
|
||||||
|
|
||||||
|
public addLogDestination = this.logRouter.addLogDestination;
|
||||||
|
|
||||||
|
constructor(optionsArg: ISmartlogContructorOptions) {
|
||||||
|
this.logContext = optionsArg.logContext;
|
||||||
|
this.minimumLogLevel = optionsArg.minimumLogLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ============
|
// ============
|
||||||
// Logger Setup
|
// Logger Setup
|
||||||
// ============
|
// ============
|
||||||
@ -33,25 +51,27 @@ export class Smartlog {
|
|||||||
* @param logLevelArg
|
* @param logLevelArg
|
||||||
* @param logMessageArg
|
* @param logMessageArg
|
||||||
*/
|
*/
|
||||||
log(logLevelArg: TLogLevel, logMessageArg: string) {}
|
public log(logLevelArg: TLogLevel, logMessageArg: string) {
|
||||||
|
if (this.consoleEnabled) {
|
||||||
silly(logMessageArg: string) {
|
console.log(`LOG: ${logLevelArg}: ${logMessageArg}`);
|
||||||
this.log('silly', logMessageArg);
|
}
|
||||||
|
this.logRouter.routeLog({
|
||||||
|
type: 'log',
|
||||||
|
context: this.logContext,
|
||||||
|
level: logLevelArg,
|
||||||
|
message: logMessageArg
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(logMessageArg) {
|
public increment(logLevelArg: TLogLevel, logMessageArg) {
|
||||||
this.log('debug', logMessageArg);
|
if (this.consoleEnabled) {
|
||||||
}
|
console.log(`INCREMENT: ${logLevelArg}: ${logMessageArg}`);
|
||||||
|
}
|
||||||
info(logMessageArg: string) {
|
this.logRouter.routeLog({
|
||||||
this.log('info', logMessageArg);
|
type: 'increment',
|
||||||
}
|
context: this.logContext,
|
||||||
|
level: logLevelArg,
|
||||||
warn(logMessageArg) {
|
message: logMessageArg
|
||||||
this.log('warn', logMessageArg);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
error(logMessageArg) {
|
|
||||||
this.log('error', logMessageArg);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1 +1 @@
|
|||||||
export {};
|
export {};
|
||||||
|
16
tslint.json
16
tslint.json
@ -1,3 +1,17 @@
|
|||||||
{
|
{
|
||||||
"extends": "tslint-config-standard"
|
"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"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user