docs: function Logsene (token, type, url, storageDirectory, options) {
    if (!token) {
      throw new Error('Logsene token not specified')
    }
    if (options) {
      this.options = options
    } else {
      this.options = {
        useIndexInBulkUrl: false
      }
    }
    if (url && /logsene/.test(url)) {
      // logs to logsene should use /TOKEN/_bulk
      this.options.useIndexInBulkUrl = true
    }
    this.request = null
    this.maxMessageFieldSize = MAX_MESSAGE_FIELD_SIZE
    this.xLogseneOrigin = xLogseneOrigin
    this.token = token
    this.setUrl(url || process.env.LOGSENE_URL || process.env.LOGSENE_RECEIVER_URL || process.env.LOGS_URL || 'https://logsene-receiver.sematext.com/_bulk')
    this.type = type || 'logs'
    this.hostname = process.env.SPM_REPORTED_HOSTNAME || os.hostname()
    this.bulkReq = new streamBuffers.WritableStreamBuffer({
      initialSize: initialBufferSize,
      incrementAmount: incrementBuffer
    })
    this.logCount = 0
    this.sourceName = null
    if (process.mainModule && process.mainModule.filename) {
      this.sourceName = path.basename(process.mainModule.filename)
    }
    events.EventEmitter.call(this)
    var self = this
    self.lastSend = Date.now()
    var logInterval = Number(process.env.LOGSENE_LOG_INTERVAL) || 20000
    var tid = setInterval(function () {
      if (self.logCount > 0 && (Date.now() - self.lastSend) > (logInterval - 1000)) {
        self.send()
      }
    }, logInterval)
    if (tid.unref) {
      tid.unref()
    }
    process.on('beforeExit', function () {
      self.send()
    })
    if (process.env.LOGSENE_TMP_DIR || storageDirectory) {
      this.diskBuffer(true, process.env.LOGSENE_TMP_DIR || storageDirectory)
    }
    var fieldListStr = process.env.LOGSENE_REMOVE_FIELDS || process.env.REMOVE_FIELDS || ''
    this.removeFieldsList = fieldListStr.replace(/ /g, '').split(',')
  }