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

39 lines
850 B
TypeScript
Raw Normal View History

2017-01-21 00:05:28 +00:00
import * as plugins from './beautylog.plugins'
2016-07-23 23:17:38 +00:00
2017-01-21 00:05:28 +00:00
let client
2016-07-23 23:17:38 +00:00
let clientData = {
2017-01-21 00:05:28 +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) => {
2017-01-21 00:05:28 +00:00
clientData.messageType = logType
clientData.message = logMessage
2016-07-23 23:30:30 +00:00
if (client) {
2017-01-21 00:05:28 +00:00
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,
2017-01-21 00:05:28 +00:00
serverName: string
2016-07-23 23:30:30 +00:00
}) => {
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
2017-01-21 00:05:28 +00:00
})
clientData.applicationName = optionsArg.appName
clientData.serverName = optionsArg.serverName
2016-07-23 23:17:38 +00:00
}
export let remote = {
loggly: loggly
2017-01-21 00:05:28 +00:00
}