Compare commits

..

22 Commits

Author SHA1 Message Date
39d08ef53a 2.0.8 2018-11-04 18:21:18 +01:00
74e6bc7a3c fix(core): update 2018-11-04 18:21:18 +01:00
5d0056558a 2.0.7 2018-11-04 15:26:40 +01:00
2b920e2f5e fix(core): update 2018-11-04 15:26:40 +01:00
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 1027 additions and 286 deletions

View File

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

View File

@ -1,8 +1,6 @@
{ {
"npmci": { "npmci": {
"npmGlobalTools": [ "npmGlobalTools": [],
"npmts"
],
"npmAccessLevel": "public" "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", "name": "@pushrocks/smartlog",
"version": "1.0.4", "version": "2.0.8",
"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.2"
} }
} }

View File

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

View File

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

View File

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

View File

@ -1,13 +1,33 @@
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, ILogDestination, ILogPackage } 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; private logRouter = new LogRouter();
public addLogDestination (logDestinationArg: ILogDestination) {
this.logRouter.addLogDestination(logDestinationArg);
}
constructor(optionsArg: ISmartlogContructorOptions) {
this.logContext = optionsArg.logContext;
this.minimumLogLevel = optionsArg.minimumLogLevel;
}
// ============ // ============
// Logger Setup // Logger Setup
// ============ // ============
@ -19,39 +39,42 @@ export class Smartlog {
this.consoleEnabled = true; this.consoleEnabled = true;
} }
/**
* set a minimum serverity level to log
* @param levelArg
*/
level(levelArg: TLogLevel) {}
// ============= // =============
// log functions // log functions
// ============= // =============
/** /**
* log stuff * main log method
* @param logLevelArg * @param logLevelArg - the log level
* @param logMessageArg * @param logMessageArg - the log message
* @param logDataArg - any additional log data
*/ */
log(logLevelArg: TLogLevel, logMessageArg: string) {} public log(logLevelArg: TLogLevel, logMessageArg: string, logDataArg?: any) {
if (this.consoleEnabled) {
silly(logMessageArg: string) { console.log(`LOG: ${logLevelArg}: ${logMessageArg}`);
this.log('silly', logMessageArg); }
const logPackage: ILogPackage = {
timestamp: Date.now(),
type: 'log',
context: this.logContext,
level: logLevelArg,
message: logMessageArg
};
if(logDataArg) {
logPackage.data = logDataArg;
}
this.logRouter.routeLog(logPackage);
} }
debug(logMessageArg) { public increment(logLevelArg: TLogLevel, logMessageArg) {
this.log('debug', logMessageArg); if (this.consoleEnabled) {
console.log(`INCREMENT: ${logLevelArg}: ${logMessageArg}`);
} }
this.logRouter.routeLog({
info(logMessageArg: string) { timestamp: Date.now(),
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);
} }
} }

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