npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@logdoc/node

v1.0.13

Published

Library for connecting the system LogDoc

Downloads

8

Readme

Node js appender for LogDoc

LogDoc is a system for collecting, analyzing and storing logs.

Logs are sent via the network in any format using any protocol to LogDoc, where they are structured, analyzed and stored.

@logdoc/node

Motivation

LogDoc An open SDK and a simple protocol make it possible to support system formats (Syslog/Journald), industry standards (Java/Python/Go logging), monitoring (collection of metrics), and any proprietary product.

LogDoc uses the ClickHouse database as its main storage, which is great for analytics. But in addition, LogDoc also provides a toolkit for integration with SIEM systems, which allows you to analyze data structures on the fly, without waiting for them to enter the storage, and take appropriate actions earlier.

An important advantage of LogDoc is its flexibility and customizability. Working with data relies on structures rather than search, which significantly speeds up the overall process and allows you to get rigorous results.

By default, LogDoc implements its own role model of users and groups, but can also be integrated with any corporate access control system.

LogDoc supports two types of plug-ins: sink (listening to incoming data) and pipe (reacting to data in structures), which means that it is possible to implement any integration with any information system.

Simple Usage

npm i @logdoc/node
import LogDoc, { Protocol } from '@logdoc/node'
const logger = new LogDoc({ host: "example.host", port: 5555, protocol: Protocol.UDP,, app: 'name app', source: 'source app' })

logger.sendLog({
    msg: "Hello Wordl",
    tsrc: new Date(),
    lvl: "ERROR",
    ip: '234.234.234.23',
    pid: 12,
    src: 'Node src',
    fields: {
        custom: 'odin',
        jios: 'ddd',
        kkssss: 'ndddd'
    }
})

Logger creation parameters.:

| Name | Default | Description | |---------------|------------------|----------------------------------------------------------------------| | host | example.host | The path to the connection host where to raise LogDoc | | port | 5555 | Port LogDoc | | protocol | tcp | Required parameter. Enum type. Valid values tcp or udp or http | | app | `` | An optional parameter specifying the app name. |

A logger accepts the following parameters message:

| Name | Default | Description | |---------------|-----------------------------|----------------------------------------------------------------------------------------------------------------------| | msg | 'info' | The message body parameter. Required. If he is not. The message will not be delivered. | | tsrc | new Date() | Source time, optional | | lvl | INFO | Required parameter. Enum type. Valid values INFO or PANIC or FATAL or ERROR or WARN or DEBUG or ERROR, | | ip | 000.000.000.00 | An optional parameter specifying the source IP. | | pid | process.pid | An optional parameter specifying the pid of the source | | src | os.hostname() | Optional parameter | | ------------- | --------------------------- | --------------- | | fields | {} | Optional parameter in which you can specify any fields |

Working with winston

const winston = require('winston')

const logger = winston.createLogger({
  level: config.env === 'development' ? 'debug' : 'info',
  format: winston.format.combine(
    enumerateErrorFormat(),
    config.env === 'development' ? winston.format.colorize() : winston.format.uncolorize(),
    winston.format.splat(),
    winston.format.printf(({ level, message }) => '{level}: {message}'),
  ),
  transports: [
    new winston.transports.Console({
      stderrLevels: ['error'],
    }),
    new LogdocTransport(),
  ],
})

module.exports = logger

import LogDoc from '@logdoc/node'
import config from './config'

const Transport = require('winston-transport')

const normalizeLog = (level) => {
  if (level.includes('info')) {
    return 'info'
  }
  if (level.includes('panic')) {
    return 'panic'
  }
  if (level.includes('fatal')) {
    return 'fatal'
  }
  if (level.includes('error')) {
    return 'error'
  }
  if (level.includes('warn')) {
    return 'warn'
  }
  if (level.includes('debug')) {
    return 'debug'
  }
  if (level.includes('trace')) {
    return 'trace'
  }
}

class LogDocTransport extends Transport {
  constructor(opts) {
    super(opts)
  }

  log(info, callback) {
    setImmediate(() => {
      this.emit('logged', info)
    })

    const { message } = info
   
    logger.sendLog({
    msg: message,
    tsrc: new Date(),
    lvl: normalizeLog(info.level),
    ip: '234.234.234.23',
    pid: 12,
    src: 'Node src',
    fields: {
        custom: 'odin',
        jios: 'ddd',
        kkssss: 'ndddd'
    }
})

    callback()
  }
}

module.exports = LogDocTransport