fix(core): update

This commit is contained in:
Philipp Kunz 2018-11-02 13:57:14 +01:00
parent 35ac4a76b8
commit e03d4872cf
6 changed files with 125 additions and 27 deletions

94
package-lock.json generated
View File

@ -74,6 +74,19 @@
"@pushrocks/smartpromise": "^2.0.5"
}
},
"@pushrocks/lik": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/@pushrocks/lik/-/lik-3.0.1.tgz",
"integrity": "sha512-6dwRg7WMdY9drlqfo6NzOcw5ubVWYvIOSSMZz4Jsojpa8aDVwXd2VkD7sxO/PJRrbZzHkx/JXoY/epcWRjngUw==",
"requires": {
"@pushrocks/smartpromise": "^2.0.5",
"@types/lodash": "^4.14.112",
"@types/minimatch": "^3.0.3",
"lodash": "^4.17.10",
"minimatch": "^3.0.4",
"symbol-tree": "^3.2.2"
}
},
"@pushrocks/qenv": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@pushrocks/qenv/-/qenv-2.0.2.tgz",
@ -87,7 +100,6 @@
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@pushrocks/smartdelay/-/smartdelay-2.0.2.tgz",
"integrity": "sha512-4xf6tMKwZcxBynKgXrM4SQKgeASfRvx43LUmR5DkStp26ZHAsarCXUdKJS6y8QIPygEOTOCP8we97JAcCzBuMg==",
"dev": true,
"requires": {
"@pushrocks/smartpromise": "^2.0.5"
}
@ -113,7 +125,6 @@
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/@pushrocks/smartlog/-/smartlog-2.0.3.tgz",
"integrity": "sha512-HbH2b6ybd1cD8VTlx5kEt4N/Vgh9TQTHKlUV4kAORFIOTJOQD5WbCMIVWo+VqYHvYQtokoYFCjM1gctp4M1aWw==",
"dev": true,
"requires": {
"@pushrocks/smartlog-interfaces": "^1.0.9"
}
@ -180,6 +191,20 @@
"smartchai": "^2.0.1"
}
},
"@pushrocks/taskbuffer": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/@pushrocks/taskbuffer/-/taskbuffer-2.0.5.tgz",
"integrity": "sha512-frzuSoz7Lhlt4y+5vP513BJ/blSalkLH1A4Es0QtxQ6258ekxP/FWC7Bq0Hy7XnNDIlws0WDvd1KN2prSIKZDg==",
"requires": {
"@pushrocks/lik": "^3.0.1",
"@pushrocks/smartdelay": "^2.0.1",
"@pushrocks/smartlog": "^2.0.1",
"@pushrocks/smartpromise": "^2.0.5",
"@types/cron": "^1.3.0",
"cron": "^1.3.0",
"rxjs": "^6.2.2"
}
},
"@types/chai": {
"version": "4.1.7",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.1.7.tgz",
@ -204,6 +229,11 @@
"@types/chai": "*"
}
},
"@types/cron": {
"version": "1.3.0",
"resolved": "http://registry.npmjs.org/@types/cron/-/cron-1.3.0.tgz",
"integrity": "sha512-RNJ6Hbxs9CbUw+Bxt8kpN8/yNlYG1xli0JZSO1xTJJxFjgD2KWctFSkJeJpjf9iLJU0jeNPoJ5LEru7eBN3xuA=="
},
"@types/figures": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@types/figures/-/figures-2.0.0.tgz",
@ -227,6 +257,16 @@
"@types/node": "*"
}
},
"@types/lodash": {
"version": "4.14.117",
"resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.117.tgz",
"integrity": "sha512-xyf2m6tRbz8qQKcxYZa7PA4SllYcay+eh25DN3jmNYY6gSTL7Htc/bttVdkqj2wfJGbeWlQiX8pIyJpKU+tubw=="
},
"@types/minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA=="
},
"@types/node": {
"version": "10.12.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.1.tgz",
@ -320,8 +360,7 @@
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
"dev": true
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"bindings": {
"version": "1.3.0",
@ -333,7 +372,6 @@
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -478,8 +516,7 @@
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
"dev": true
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
},
"core-util-is": {
"version": "1.0.2",
@ -487,6 +524,14 @@
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
"dev": true
},
"cron": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/cron/-/cron-1.5.0.tgz",
"integrity": "sha512-j7zMFLrcSta53xqOvETUt8ge+PM14GtF47gEGJJeVlM6qP24/eWHSgtiWiEiKBR2sHS8xZaBQZq4D7vFXg8dcQ==",
"requires": {
"moment-timezone": "^0.5.x"
}
},
"crypto-random-string": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/crypto-random-string/-/crypto-random-string-1.0.0.tgz",
@ -715,6 +760,11 @@
"integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==",
"dev": true
},
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"make-error": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
@ -743,7 +793,6 @@
"version": "3.0.4",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
"integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
"dev": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -771,6 +820,19 @@
}
}
},
"moment": {
"version": "2.22.2",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz",
"integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y="
},
"moment-timezone": {
"version": "0.5.23",
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.23.tgz",
"integrity": "sha512-WHFH85DkCfiNMDX5D3X7hpNH3/PUhjTGcD0U1SgfBGZxJ3qUmJh5FdvaFjcClxOvB3rzdfj4oRffbI38jEnC1w==",
"requires": {
"moment": ">= 2.9.0"
}
},
"nan": {
"version": "2.11.1",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.11.1.tgz",
@ -873,6 +935,14 @@
"path-parse": "^1.0.5"
}
},
"rxjs": {
"version": "6.3.3",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.3.3.tgz",
"integrity": "sha512-JTWmoY9tWCs7zvIk/CvRjhjGaOd+OVBM987mxFo+OW66cGpdKjZcpmc74ES1sB//7Kl/PAe8+wEakuhG4pcgOw==",
"requires": {
"tslib": "^1.9.0"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
@ -978,6 +1048,11 @@
"integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=",
"dev": true
},
"symbol-tree": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz",
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY="
},
"ts-node": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
@ -997,8 +1072,7 @@
"tslib": {
"version": "1.9.3",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz",
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==",
"dev": true
"integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ=="
},
"tslint": {
"version": "5.11.0",

View File

@ -24,6 +24,7 @@
"dependencies": {
"@pushrocks/smartlog-interfaces": "^1.0.15",
"@pushrocks/smartrequest": "^1.1.14",
"@pushrocks/smartstring": "^3.0.4"
"@pushrocks/smartstring": "^3.0.4",
"@pushrocks/taskbuffer": "^2.0.5"
}
}

View File

@ -1,2 +1,2 @@
vars:
-
- LGDNA_APIKEY

View File

@ -9,11 +9,22 @@ let testLogDnaAccount: logdna.LogdnaAccount;
let testLogMessage: logdna.LogdnaMessage;
tap.test('should create a valid logDna account', async () => {
testLogDnaAccount = new logdna.LogdnaAccount();
testLogDnaAccount = new logdna.LogdnaAccount(process.env.LOGDNA_APIKEY);
});
tap.test('should create a standard log message', async () => {
testLogMessage = logdna.LogdnaMessage.fromSmartLogPackage({
logContext: {
company: 'Lossless GmbH',
companyunit: 'lossless.cloud',
containerName: 'ci-mojoio-logdna',
environment: 'test',
runtime: 'node',
zone: 'ship.zone'
},
logLevel: 'info',
message: 'this is a awesome log message :)'
});
});
tap.start();

View File

@ -44,7 +44,7 @@ export interface ILogdnaMessageContructorOptions {
/**
* any metadata that is used
*/
metaData: any;
meta: any;
/**
* an array of strings
@ -56,21 +56,33 @@ export interface ILogdnaMessageContructorOptions {
* a basic LogdnaMessage
*/
export class LogdnaMessage {
/**
* create lgdna messages from smartlog package
* @param smartlogPackageArg
*/
static fromSmartLogPackage (smartlogPackageArg: ILogPackage): LogdnaMessage {
return new LogdnaMessage({
line: smartlogPackageArg.message,
metaData: smartlogPackageArg.logContext,
meta: smartlogPackageArg.logContext,
env: smartlogPackageArg.logContext.environment,
hostname: smartlogPackageArg.logContext.zone,
level: smartlogPackageArg.logLevel,
app: smartlogPackageArg.logContext.zone,
tags: [],
tags: (() => {
const tagArray: string[] = [];
tagArray.push(smartlogPackageArg.logContext.company);
tagArray.push(smartlogPackageArg.logContext.companyunit);
return tagArray;
})(),
ip: '0.0.0.0',
mac: 'aa:aa:aa:aa:aa:aa'
});
};
options: ILogdnaMessageContructorOptions;
/**
* the options of this log message
*/
public options: ILogdnaMessageContructorOptions;
constructor(optionsArg: ILogdnaMessageContructorOptions) {
this.options = optionsArg;
};

View File

@ -32,9 +32,13 @@ export class LogdnaAccount {
public async sendLogDnaMessage(logdnaMessageArg: LogdnaMessage) {
const lm = logdnaMessageArg;
const euc = encodeURIComponent;
// let construct the request uri
const requestUrlWithParams = `${this.baseUrl}?hostname=${euc(
lm.options.hostname
)}&mac=${euc(lm.options.mac)}&ip=1${euc(lm.options.ip)}&now=${Date.now()}`;
// lets post the message to logdna
await plugins.smartrequest.postJson(requestUrlWithParams, {
headers: {
'Authorization': this.createBasicAuth(),
@ -43,15 +47,11 @@ export class LogdnaAccount {
requestBody: {
"lines": [
{
"line":"This is an awesome log statement",
"app":"myapp",
"level": "INFO",
"env": "production",
"meta": {
"customfield": {
"nestedfield": "nestedvalue"
}
}
"line": lm.options.line,
"app": lm.options.app,
"level": lm.options.level,
"env": lm.options.env,
"meta": lm.options.meta
}
]
}