UNPKG

ihub-framework-js

Version:

Legacy version of iHub Framework written in Javascript

23 lines (18 loc) 729 B
const ElasticsearchTransport = require('winston-elasticsearch'); const Elasticsearch = require('elasticsearch'); module.exports = () => { const configOpts = { host: `${process.env.ELASTICSEARCH_HOST}:${process.env.ELASTICSEARCH_LOG_PORT}`, log: 'error', }; if (process.env.ELASTICSEARCH_REQUEST_TIMEOUT) { configOpts.requestTimeout = process.env.ELASTICSEARCH_REQUEST_TIMEOUT; } const client = new Elasticsearch.Client(configOpts); const esTransportOpts = { indexPrefix: `logs-${process.env.PROJECT_NAMESPACE}-${process.env.NODE_ENV || 'development'}`, level: process.env.NODE_ENV === 'development' ? 'debug' : 'info', client, }; return new ElasticsearchTransport(esTransportOpts); };