Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
7dac427f00 | |||
e451c38f32 | |||
540e5be2fa | |||
7d29f88356 | |||
9d81f059fe | |||
52cdf6f9fe | |||
1339db1adf | |||
2b42bd59c5 | |||
4cd9ce8510 | |||
cf2620bd41 | |||
1d1a438f8e | |||
aec150a240 | |||
958a5d4db5 | |||
3a2af6634d | |||
d89b610006 | |||
56bc5dfcdd | |||
f49062d247 | |||
bd45505c6a | |||
e7f2ecc8d6 | |||
3950af87bd |
23382
package-lock.json
generated
23382
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@mojoio/logdna",
|
"name": "@mojoio/logdna",
|
||||||
"version": "1.0.25",
|
"version": "1.0.35",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "an unoffical package for the logdna api",
|
"description": "an unoffical package for the logdna api",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@ -13,20 +13,20 @@
|
|||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tstest": "^1.0.33",
|
"@gitzone/tstest": "^1.0.54",
|
||||||
"@pushrocks/qenv": "^4.0.6",
|
"@pushrocks/qenv": "^4.0.10",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.0.9",
|
"@types/node": "^14.0.11",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/lik": "^4.0.13",
|
"@pushrocks/lik": "^4.0.20",
|
||||||
"@pushrocks/smartlog-interfaces": "^2.0.9",
|
"@pushrocks/smartlog-interfaces": "^2.0.22",
|
||||||
"@pushrocks/smartrequest": "^1.1.47",
|
"@pushrocks/smartrequest": "^1.1.52",
|
||||||
"@pushrocks/smartstring": "^3.0.18",
|
"@pushrocks/smartstring": "^3.0.24",
|
||||||
"@pushrocks/taskbuffer": "^2.1.1"
|
"@pushrocks/taskbuffer": "^2.1.13"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
17
readme.md
17
readme.md
@ -27,11 +27,12 @@ Platform support | [;
|
|||||||
// most of the above funtions return promises should you want to wait for a log to be fully sent
|
// most of the above funtions return promises should you want to wait for a log to be fully sent
|
||||||
```
|
```
|
||||||
|
|
||||||
For further information read the linked docs at the top of this README.
|
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
|
||||||
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
|
||||||
|
|
||||||
[](https://mojo.io)
|
|
||||||
|
|
||||||
|
|
||||||
## Contribution
|
## Contribution
|
||||||
|
|
||||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
||||||
|
38
test/test.ts
38
test/test.ts
@ -26,6 +26,10 @@ tap.test('should create a standard log message', async () => {
|
|||||||
runtime: 'node',
|
runtime: 'node',
|
||||||
zone: 'shipzone'
|
zone: 'shipzone'
|
||||||
},
|
},
|
||||||
|
correlation: {
|
||||||
|
id: '123',
|
||||||
|
type: 'none'
|
||||||
|
},
|
||||||
message: 'this is an awesome log message sent by the tapbundle test'
|
message: 'this is an awesome log message sent by the tapbundle test'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -49,13 +53,17 @@ tap.test('should send in order', async () => {
|
|||||||
runtime: 'node',
|
runtime: 'node',
|
||||||
zone: 'shipzone'
|
zone: 'shipzone'
|
||||||
},
|
},
|
||||||
message: `this is an awesome log message sent by the tapbundle test #${i}`
|
message: `this is an awesome log message sent by the tapbundle test #${i}`,
|
||||||
|
correlation: {
|
||||||
|
id: '123',
|
||||||
|
type: 'none'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
testLogDnaAccount.sendSmartlogPackage(testSmartlogMessage);
|
testLogDnaAccount.sendSmartlogPackage(testSmartlogMessage);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const testSmartlogMessage: ILogPackage = {
|
const testSmartlogMessage2: ILogPackage = {
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
type: 'log',
|
type: 'log',
|
||||||
level: 'warn',
|
level: 'warn',
|
||||||
@ -67,9 +75,33 @@ tap.test('should send in order', async () => {
|
|||||||
runtime: 'node',
|
runtime: 'node',
|
||||||
zone: 'shipzone'
|
zone: 'shipzone'
|
||||||
},
|
},
|
||||||
|
correlation: {
|
||||||
|
id: '123',
|
||||||
|
type: 'none'
|
||||||
|
},
|
||||||
message: `this is an awesome log message sent by the tapbundle test #${i}`
|
message: `this is an awesome log message sent by the tapbundle test #${i}`
|
||||||
};
|
};
|
||||||
testLogDnaAccount.sendSmartlogPackage(testSmartlogMessage);
|
testLogDnaAccount.sendSmartlogPackage(testSmartlogMessage2);
|
||||||
|
|
||||||
|
const testSmartlogMessage3: ILogPackage = {
|
||||||
|
timestamp: Date.now(),
|
||||||
|
type: 'log',
|
||||||
|
level: 'error',
|
||||||
|
context: {
|
||||||
|
company: 'Lossless GmbH',
|
||||||
|
companyunit: 'lossless.cloud',
|
||||||
|
containerName: 'ci-mojoio-logdna',
|
||||||
|
environment: 'test',
|
||||||
|
runtime: 'node',
|
||||||
|
zone: 'shipzone'
|
||||||
|
},
|
||||||
|
correlation: {
|
||||||
|
id: '123',
|
||||||
|
type: 'none'
|
||||||
|
},
|
||||||
|
message: `this is an awesome log message sent by the tapbundle test #${i}`
|
||||||
|
};
|
||||||
|
testLogDnaAccount.sendSmartlogPackage(testSmartlogMessage3);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -41,8 +41,9 @@ export class LogAggregator {
|
|||||||
private async sendAggregatedLogs(logCandidate: ILogCandidate) {
|
private async sendAggregatedLogs(logCandidate: ILogCandidate) {
|
||||||
this.logObjectMap.remove(logCandidate);
|
this.logObjectMap.remove(logCandidate);
|
||||||
// lets post the message to logdna
|
// lets post the message to logdna
|
||||||
|
const url = `${this.baseUrl}${logCandidate.urlIdentifier}&now=${Date.now()}`;
|
||||||
const response = await plugins.smartrequest.postJson(
|
const response = await plugins.smartrequest.postJson(
|
||||||
`${this.baseUrl}${logCandidate.urlIdentifier}&now=${Date.now()}`,
|
url,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: this.createBasicAuth(),
|
Authorization: this.createBasicAuth(),
|
||||||
|
@ -71,7 +71,9 @@ export class LogdnaMessage {
|
|||||||
line: smartlogPackageArg.message,
|
line: smartlogPackageArg.message,
|
||||||
meta: {
|
meta: {
|
||||||
...smartlogPackageArg.context,
|
...smartlogPackageArg.context,
|
||||||
logType: smartlogPackageArg.type
|
logType: smartlogPackageArg.type,
|
||||||
|
correlation: smartlogPackageArg.correlation,
|
||||||
|
data: smartlogPackageArg.data || {}
|
||||||
},
|
},
|
||||||
env: smartlogPackageArg.context.environment,
|
env: smartlogPackageArg.context.environment,
|
||||||
hostname: smartlogPackageArg.context.zone,
|
hostname: smartlogPackageArg.context.zone,
|
||||||
|
@ -31,11 +31,16 @@ export class LogdnaAccount {
|
|||||||
const uriIp = euc(lm.options.ip);
|
const uriIp = euc(lm.options.ip);
|
||||||
const uriTags = euc(
|
const uriTags = euc(
|
||||||
(() => {
|
(() => {
|
||||||
|
let first = true;
|
||||||
return lm.options.tags.reduce((reduced, newItem) => {
|
return lm.options.tags.reduce((reduced, newItem) => {
|
||||||
return `${reduced},${newItem}`;
|
if (first) {
|
||||||
|
first = false;
|
||||||
|
reduced = euc(reduced);
|
||||||
|
}
|
||||||
|
return `${reduced},euc(${newItem})`;
|
||||||
});
|
});
|
||||||
})()
|
})()
|
||||||
);
|
)
|
||||||
|
|
||||||
// let construct the request uri
|
// let construct the request uri
|
||||||
const requestUrlWithParams = `?hostname=${uriHostname}&mac=${uriMac}&ip=1${uriIp}&tags=${uriTags}`;
|
const requestUrlWithParams = `?hostname=${uriHostname}&mac=${uriMac}&ip=1${uriIp}&tags=${uriTags}`;
|
||||||
@ -64,7 +69,7 @@ export class LogdnaAccount {
|
|||||||
*/
|
*/
|
||||||
public get smartlogDestination(): ILogDestination {
|
public get smartlogDestination(): ILogDestination {
|
||||||
return {
|
return {
|
||||||
handleLog: logPackageArg => {
|
handleLog: async logPackageArg => {
|
||||||
this.sendSmartlogPackage(logPackageArg);
|
this.sendSmartlogPackage(logPackageArg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user