1.0.0 • Published 5 years ago

@churchill/elastic v1.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

Elastic transport

Index your logged data to elasticsearch.

npm install @churchill/elastic @elastic/elasticsearch@^7.0.0

Usage

const churchill = require("@churchill/core");
const Elastic = require("@churchill/elastic");

const elasticTransport = Elastic.create({
  node: "http://localhost:9200",
  index: "churchill-logs",
  format: info => ({
    level: info.level,
    namespace: info.namespace,
    timestamp: info.timestamp,
    payload: JSON.stringify(info.args)
  })
})
elasticTransport.on("error", (err) => {
  // ... you should handle errors
});

const createNamespace = churchill({
  transports: [elasticTransport]
});

const logger = createNamespace("worker:1");
logger.info("...");

Options

OptionDescriptionExample
clientElasticsearch client (or just pass a node URL)new Client({ node: "..." })
nodeElasticsearch node URL{ node: "http://localhost:9200" }
indexIndex where to store logs.churchill-log
formatCustom formatting function.{ format: (info, out, logger) => ... }
maxLevelMax level to log into this transport.{ maxLevel: "warn" }

Events

NameParamsDescription
errorerror: ErrorEmited when indexing throws an Error