Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
c9c38368c1 | |||
640eddae2d | |||
ade4d86597 | |||
d4cc9dbcd0 | |||
cde3686209 | |||
485e04c0b3 | |||
0ee2b8295a | |||
4fd4de20c2 | |||
accf03f1b4 | |||
8e8e2c7bd6 |
@ -26,6 +26,7 @@ mirror:
|
||||
snyk:
|
||||
stage: security
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci command npm install -g snyk
|
||||
- npmci command npm install --ignore-scripts
|
||||
- npmci command snyk test
|
||||
@ -39,6 +40,7 @@ snyk:
|
||||
testLEGACY:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install legacy
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -51,6 +53,7 @@ testLEGACY:
|
||||
testLTS:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install lts
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -62,6 +65,7 @@ testLTS:
|
||||
testSTABLE:
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
- npmci npm install
|
||||
- npmci npm test
|
||||
@ -117,8 +121,10 @@ pages:
|
||||
image: hosttoday/ht-docker-node:npmci
|
||||
stage: metadata
|
||||
script:
|
||||
- npmci command npm install -g npmpage
|
||||
- npmci command npmpage
|
||||
- npmci command npm install -g typedoc typescript
|
||||
- npmci npm prepare
|
||||
- npmci npm install
|
||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
||||
tags:
|
||||
- docker
|
||||
- notpriv
|
||||
@ -128,3 +134,14 @@ pages:
|
||||
expire_in: 1 week
|
||||
paths:
|
||||
- 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": {
|
||||
"npmGlobalTools": [
|
||||
"npmts"
|
||||
],
|
||||
"npmGlobalTools": [],
|
||||
"npmAccessLevel": "public"
|
||||
}
|
||||
}
|
||||
|
1115
package-lock.json
generated
1115
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",
|
||||
"version": "1.0.5",
|
||||
"version": "2.0.3",
|
||||
"private": false,
|
||||
"description": "winston based logger for large scale projects",
|
||||
"main": "dist/index.js",
|
||||
@ -8,16 +8,20 @@
|
||||
"author": "Lossless GmbH",
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"test": "(tsrun test/test.ts)",
|
||||
"build": "echo \"Not needed for now\"",
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild)",
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsrun": "^1.0.4",
|
||||
"cz-conventional-changelog": "^2.1.0",
|
||||
"tapbundle": "^1.0.13"
|
||||
"@gitzone/tsbuild": "^2.0.22",
|
||||
"@gitzone/tsrun": "^1.1.13",
|
||||
"@gitzone/tstest": "^1.0.15",
|
||||
"@pushrocks/tapbundle": "^3.0.7",
|
||||
"@types/node": "^10.12.1",
|
||||
"tslint": "^5.11.0",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"smartlog-interfaces": "^1.0.4"
|
||||
"@pushrocks/smartlog-interfaces": "^1.0.9"
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { expect, tap } from 'tapbundle';
|
||||
import { expect, tap } from '@pushrocks/tapbundle';
|
||||
import * as smartlog from '../ts/index';
|
||||
|
||||
let defaultLogger: smartlog.Smartlog;
|
||||
|
||||
tap.test('should produce instance of Smartlog', async () => {
|
||||
defaultLogger = smartlog.getDefaultLogger();
|
||||
defaultLogger = smartlog.defaultLogger;
|
||||
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 { Smartlog } from './smartlog.classes.smartlog';
|
||||
|
||||
export { Smartlog };
|
||||
|
||||
let defaultLogger: Smartlog;
|
||||
|
||||
export const getDefaultLogger = () => {
|
||||
if (!defaultLogger) {
|
||||
defaultLogger = new Smartlog();
|
||||
const defaultLogger: Smartlog = new Smartlog({
|
||||
logContext: {
|
||||
company: 'undefined',
|
||||
companyunit: 'undefefined',
|
||||
containerName: 'undefined',
|
||||
environment: 'local',
|
||||
runtime: 'node',
|
||||
zone: 'undefined'
|
||||
}
|
||||
return defaultLogger;
|
||||
};
|
||||
});
|
||||
|
||||
export { Smartlog, defaultLogger };
|
||||
|
@ -1,10 +1,23 @@
|
||||
import * as plugins from './smartlog.plugins';
|
||||
|
||||
import { ILogDestination } from 'smartlog-interfaces';
|
||||
import { ILogDestination, ILogPackage } from '@pushrocks/smartlog-interfaces';
|
||||
|
||||
export class LogRouter {
|
||||
logDestinations: ILogDestination[] = [];
|
||||
/**
|
||||
* all log destinations
|
||||
*/
|
||||
private logDestinations: ILogDestination[] = [];
|
||||
|
||||
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';
|
||||
|
||||
// interfaces
|
||||
import { TEnvironment, ILogContext, TLogLevel, TRuntime } from 'smartlog-interfaces';
|
||||
import { TEnvironment, ILogContext, TLogLevel, TRuntime } from '@pushrocks/smartlog-interfaces';
|
||||
|
||||
import { LogRouter } from './smartlog.classes.logrouter';
|
||||
|
||||
export interface ISmartlogContructorOptions {
|
||||
logContext: ILogContext;
|
||||
minimumLogLevel?: TLogLevel;
|
||||
}
|
||||
|
||||
export class Smartlog {
|
||||
private logContext: ILogContext;
|
||||
private minimumLogLevel: TLogLevel;
|
||||
|
||||
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
|
||||
// ============
|
||||
@ -33,25 +51,34 @@ export class Smartlog {
|
||||
* @param logLevelArg
|
||||
* @param logMessageArg
|
||||
*/
|
||||
log(logLevelArg: TLogLevel, logMessageArg: string) {}
|
||||
public log(logLevelArg: TLogLevel, logMessageArg: string) {
|
||||
if (this.consoleEnabled) {
|
||||
console.log(`${logLevelArg}: ${logMessageArg}`);
|
||||
}
|
||||
this.logRouter.routeLog({
|
||||
logContext: this.logContext,
|
||||
logLevel: logLevelArg,
|
||||
message: logMessageArg
|
||||
});
|
||||
}
|
||||
|
||||
silly(logMessageArg: string) {
|
||||
public silly(logMessageArg: string) {
|
||||
this.log('silly', logMessageArg);
|
||||
}
|
||||
|
||||
debug(logMessageArg) {
|
||||
public debug(logMessageArg) {
|
||||
this.log('debug', logMessageArg);
|
||||
}
|
||||
|
||||
info(logMessageArg: string) {
|
||||
public info(logMessageArg: string) {
|
||||
this.log('info', logMessageArg);
|
||||
}
|
||||
|
||||
warn(logMessageArg) {
|
||||
public warn(logMessageArg) {
|
||||
this.log('warn', logMessageArg);
|
||||
}
|
||||
|
||||
error(logMessageArg) {
|
||||
public error(logMessageArg) {
|
||||
this.log('error', logMessageArg);
|
||||
}
|
||||
}
|
||||
|
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