Skip to content

Send Moleculer logs to any endpoint (DataDog, LogTail, Newrelic, etc)

License

Notifications You must be signed in to change notification settings

1xtr/moleculer-universal-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moleculer logo

NPM version NPM Downloads

Send Moleculer logs to any endpoint (DataDog, LogTail, Newrelic, etc)

Description

You can send Moleculer logs to any endpoint

Log format:

{
    timestamp: 1682190435415, // Date.now()
    level: "info", // "fatal", "error", "warn", "info", "debug", "trace"
    message: "{}", // JSON.stringify of log args
    nodeID: "mol-repl_6428", // Unique node identifier
    namespace: "local", // Namespace of nodes to segment your nodes on the same network
    service: "repl", // service name
    source: "v1.repl", // broker, registry, discovery, transporter, cacher
    hostname: "linux",
    version: 1, // service version
}

Install

$ npm install @1xtr/moleculer-universal-logger

Import

// ES5 example
const UniversalLogger = require('@1xtr/moleculer-universal-logger')

// ES6+ example
import { UniversalLogger } from '@1xtr/moleculer-universal-logger'

Usage

module.exports = {
  logger: new UniversalLogger({
    // put here your options
    url: 'https://log-api.eu.newrelic.com/log/v1?Api-Key=your_key' // newrelic EU
  }),
}

Default options

const defaultOptions = {
  url: process.env.UNIVERSAL_LOGGER_URL,
  fetchOptions: {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
  },
  hostname: hostname(),
  objectPrinter: null,
  interval: 10 * 1000,
  excludeModules: [], // broker, registry, discovery, transporter, cacher
}

About

Send Moleculer logs to any endpoint (DataDog, LogTail, Newrelic, etc)

Resources

License

Stars

Watchers

Forks

Packages

No packages published