Skip to content

Commit

Permalink
added logType
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanrahic committed Oct 8, 2020
1 parent 922d98a commit 56978cc
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,28 +340,38 @@ Logsene.prototype.diskBuffer = function (enabled, dir) {
*/
Logsene.prototype.log = function (level, message, fields, callback) {
this.logCount = this.logCount + 1
var type = fields ? fields._type : this.type
let type = 'logs'
let logType = 'logs'

if (fields) {
logType = fields._type
}

if (this.options.useIndexInBulkUrl) {
// not a Sematext service -> use only one type per index
// Elasticsearch > 6.x allows only one type per index
type = this.type
}
var elasticsearchDocId = null
if (fields && fields._type) {
delete fields._type
}
if (fields && fields._id) {
elasticsearchDocId = fields._id
}

var msg = {
'@timestamp': new Date(),
message: message,
severity: level,
message,
logType,
os: {
host: this.hostname,
hostip: ipAddress
}
}

var elasticsearchDocId = null
if (fields && fields._type) {
delete fields._type
}
if (fields && fields._id) {
elasticsearchDocId = fields._id
}

if (disableJsonEnrichment) {
msg = {}
}
Expand Down

0 comments on commit 56978cc

Please sign in to comment.