Compare commits

..

18 Commits

Author SHA1 Message Date
793cd38381 2.0.6 2018-11-04 14:19:31 +01:00
7a05e4484d fix(api): streamline api 2018-11-04 14:19:31 +01:00
2fe657f5af 2.0.5 2018-11-04 02:41:18 +01:00
5508beae25 fix(core): update 2018-11-04 02:41:18 +01:00
f2c0f1acff 2.0.4 2018-11-03 23:19:15 +01:00
5805cc51a6 fix(core): update 2018-11-03 23:19:15 +01:00
c9c38368c1 2.0.3 2018-10-31 18:51:54 +01:00
640eddae2d fix(core): update 2018-10-31 18:51:54 +01:00
ade4d86597 2.0.2 2018-10-30 18:56:27 +01:00
d4cc9dbcd0 fix(core): implement log router 2018-10-30 18:56:26 +01:00
cde3686209 2.0.1 2018-07-10 22:36:53 +02:00
485e04c0b3 fix(.enableConsole()): now works 2018-07-10 22:36:53 +02:00
0ee2b8295a 2.0.0 2018-07-10 22:34:33 +02:00
4fd4de20c2 BREAKING CHANGE(core): now has simple defaultLogger 2018-07-10 22:34:33 +02:00
accf03f1b4 1.0.6 2018-07-08 22:30:22 +02:00
8e8e2c7bd6 fix(npm): package distribution 2018-07-08 22:30:21 +02:00
698d5927cc 1.0.5 2018-06-05 20:49:54 +02:00
3d8e2f881b fix(package): update package name 2018-06-05 20:49:54 +02:00
10 changed files with 1015 additions and 283 deletions

View File

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

View File

@ -1,8 +1,6 @@
{
"npmci": {
"npmGlobalTools": [
"npmts"
],
"npmGlobalTools": [],
"npmAccessLevel": "public"
}
}

1123
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "smartlog",
"version": "1.0.4",
"name": "@pushrocks/smartlog",
"version": "2.0.6",
"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.2",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {
"smartlog-interfaces": "^1.0.4"
"@pushrocks/smartlog-interfaces": "^2.0.1"
}
}

View File

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

View File

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

View File

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

View File

@ -1,13 +1,31 @@
import * as plugins from './smartlog.plugins';
// 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 {
private logContext: ILogContext;
private minimumLogLevel: TLogLevel;
private consoleEnabled: boolean;
private minimumLevel: TLogLevel;
private runtime: TRuntime;
private logRouter = new LogRouter();
public addLogDestination = this.logRouter.addLogDestination;
constructor(optionsArg: ISmartlogContructorOptions) {
this.logContext = optionsArg.logContext;
this.minimumLogLevel = optionsArg.minimumLogLevel;
}
// ============
// Logger Setup
// ============
@ -19,12 +37,6 @@ export class Smartlog {
this.consoleEnabled = true;
}
/**
* set a minimum serverity level to log
* @param levelArg
*/
level(levelArg: TLogLevel) {}
// =============
// log functions
// =============
@ -33,25 +45,27 @@ export class Smartlog {
* @param logLevelArg
* @param logMessageArg
*/
log(logLevelArg: TLogLevel, logMessageArg: string) {}
silly(logMessageArg: string) {
this.log('silly', logMessageArg);
public log(logLevelArg: TLogLevel, logMessageArg: string) {
if (this.consoleEnabled) {
console.log(`LOG: ${logLevelArg}: ${logMessageArg}`);
}
this.logRouter.routeLog({
type: 'log',
context: this.logContext,
level: logLevelArg,
message: logMessageArg
});
}
debug(logMessageArg) {
this.log('debug', logMessageArg);
public increment(logLevelArg: TLogLevel, logMessageArg) {
if (this.consoleEnabled) {
console.log(`INCREMENT: ${logLevelArg}: ${logMessageArg}`);
}
info(logMessageArg: string) {
this.log('info', logMessageArg);
}
warn(logMessageArg) {
this.log('warn', logMessageArg);
}
error(logMessageArg) {
this.log('error', logMessageArg);
this.logRouter.routeLog({
type: 'increment',
context: this.logContext,
level: logLevelArg,
message: logMessageArg
});
}
}

View File

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