fix(core): update

This commit is contained in:
2018-11-03 23:31:26 +01:00
parent 99bfc485cf
commit 6c471f3722
5 changed files with 36 additions and 20 deletions

View File

@ -63,15 +63,15 @@ export class LogdnaMessage {
static fromSmartLogPackage(smartlogPackageArg: ILogPackage): LogdnaMessage {
return new LogdnaMessage({
line: smartlogPackageArg.message,
meta: smartlogPackageArg.logContext,
env: smartlogPackageArg.logContext.environment,
hostname: smartlogPackageArg.logContext.zone,
level: smartlogPackageArg.logLevel,
app: smartlogPackageArg.logContext.zone,
meta: smartlogPackageArg.context,
env: smartlogPackageArg.context.environment,
hostname: smartlogPackageArg.context.zone,
level: smartlogPackageArg.level,
app: smartlogPackageArg.context.zone,
tags: (() => {
const tagArray: string[] = [];
tagArray.push(smartlogPackageArg.logContext.company);
tagArray.push(smartlogPackageArg.logContext.companyunit);
tagArray.push(smartlogPackageArg.context.company);
tagArray.push(smartlogPackageArg.context.companyunit);
return tagArray;
})(),
ip: '0.0.0.0',

View File

@ -1,18 +1,19 @@
import * as plugins from './logdna.plugins';
import { LogdnaMessage } from './logdna.classes.logmessage';
import { ILogPackage } from '@pushrocks/smartlog-interfaces';
/**
* the main logdna account
*/
export class LogdnaAccount {
apiKey: string;
baseUrl = 'https://logs.logdna.com/logs/ingest';
private apiKey: string;
private baseUrl = 'https://logs.logdna.com/logs/ingest';
/**
* Create basic authentication
*/
createBasicAuth() {
private createBasicAuth() {
const userNamePasswordString = `${this.apiKey}:`;
return `Basic ${plugins.smartstring.base64.encode(userNamePasswordString)}`;
}
@ -66,4 +67,11 @@ export class LogdnaAccount {
requestBody: requestBodyObject
});
}
/**
* convenience function for smartlog
*/
async sendSmartlogPackage (smartlogPackageArg: ILogPackage) {
this.sendLogDnaMessage(LogdnaMessage.fromSmartLogPackage(smartlogPackageArg));
}
}