smartlog-destination-local/ts/beautylog.remote.ts

38 lines
857 B
TypeScript
Raw Normal View History

2016-07-23 23:17:38 +00:00
import * as plugins from "./beautylog.plugins";
let client;
let clientData = {
2016-07-23 23:30:30 +00:00
serverName: "myServer",
applicationName: "myApp",
message: "undefined",
messageType: "undefined"
2016-07-23 23:17:38 +00:00
}
2016-07-23 23:30:30 +00:00
export let remoteLog = (logType: string, logMessage: string) => {
2016-07-23 23:17:38 +00:00
clientData.messageType = logType;
clientData.message = logMessage;
2016-07-23 23:30:30 +00:00
if (client) {
client.log(clientData);
2016-07-23 23:17:38 +00:00
};
}
// Service implementations
2016-07-23 23:30:30 +00:00
let loggly = (optionsArg: {
2016-07-23 23:47:35 +00:00
token: string,
subdomain: string,
2016-07-23 23:30:30 +00:00
appName: string,
serverName:string
}) => {
2016-07-23 23:17:38 +00:00
client = plugins.loggly.createClient({
2016-07-23 23:47:35 +00:00
token: optionsArg.token,
subdomain: optionsArg.subdomain,
2016-07-23 23:30:30 +00:00
tags: [],
json: true
2016-07-23 23:17:38 +00:00
});
2016-07-23 23:30:30 +00:00
clientData.applicationName = optionsArg.appName;
clientData.serverName = optionsArg.serverName;
2016-07-23 23:17:38 +00:00
}
export let remote = {
loggly: loggly
};