...
|
...
|
@@ -28,7 +28,7 @@ class TcpTransport extends BaseTransport { |
|
|
super(options);
|
|
|
this.name = "tcpInfuxdbLogger";
|
|
|
let that = this;
|
|
|
this.initDatabase(function () {
|
|
|
this.initDatabase(function() {
|
|
|
that.isCreated = true;
|
|
|
that.options.line = false;
|
|
|
that.addLine();
|
...
|
...
|
@@ -45,13 +45,13 @@ class TcpTransport extends BaseTransport { |
|
|
let opts = this.makeReq(path, 'GET');
|
|
|
|
|
|
//send to influxdb create database
|
|
|
let req = http.request(opts, function (res) {
|
|
|
let req = http.request(opts, function(res) {
|
|
|
let chunks = [];
|
|
|
res.on("data", function (chunk) {
|
|
|
res.on("data", function(chunk) {
|
|
|
chunks.push(chunk);
|
|
|
});
|
|
|
|
|
|
res.on("end", function () {
|
|
|
res.on("end", function() {
|
|
|
let body = Buffer.concat(chunks);
|
|
|
callback(res, body.toString());
|
|
|
});
|
...
|
...
|
@@ -85,7 +85,6 @@ class TcpTransport extends BaseTransport { |
|
|
options = this.makeReq(path, 'POST'),
|
|
|
line = logger.options.line,
|
|
|
logs = logger.logs;
|
|
|
|
|
|
//if influxdb database uninit,add line to a array;
|
|
|
if (!logger.isCreated) {
|
|
|
logger.logs.push({
|
...
|
...
|
@@ -95,14 +94,14 @@ class TcpTransport extends BaseTransport { |
|
|
} else {
|
|
|
|
|
|
//send to influxdb
|
|
|
this.sendLine(options,line);
|
|
|
this.sendLine(options, line);
|
|
|
if (logs.length < 1) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
//send logs's line to influxdb
|
|
|
for (var i = 0; i < logs.length; i++) {
|
|
|
this.sendLine(logs[i].opts,logs[i].line);
|
|
|
this.sendLine(logs[i].opts, logs[i].line);
|
|
|
}
|
|
|
|
|
|
// empty logs array.
|
...
|
...
|
@@ -116,7 +115,7 @@ class TcpTransport extends BaseTransport { |
|
|
* @param {Object} options request
|
|
|
* @param {String} line influxdb line
|
|
|
*/
|
|
|
sendLine(options,line) {
|
|
|
sendLine(options, line) {
|
|
|
if (!line) {
|
|
|
return;
|
|
|
}
|
...
|
...
|
|