<commit_before>/**
 * (C) 2013 Sazze, Inc.
 * MIT LICENCE
 *
 * Based on a gist by mbrevoort.
 * Available at: https://gist.github.com/mbrevoort/5848179
 *
 * Inspired by winston-logstash
 * Available at: https://github.com/jaakkos/winston-logstash
 */

// Really simple Winston Logstash UDP Logger

const dgram = require("dgram"),
  os = require("os"),
  winston = require("winston"),
  Transport = require("winston-transport"),
  fastq = require("fastq"),
  ReDNS = require("redns"),
  debug = require("debug")("winston-logstash-udp");

const { LEVEL } = require("triple-beam");

const NOOP = () => {};

const r = new ReDNS();

class Sender {
  constructor(host, port) {
    this.host = host;
    this.port = port;
    this.client = null;

    this.queue = fastq(this, this._send, 1);
  }

  _connect() {
    this.client = dgram.createSocket({
      type: "udp4",
      lookup: r.lookup.bind(r)
    });

    // Attach an error listener on the socket
    // It can also avoid top level exceptions like UDP DNS errors thrown by the socket
    this.client.on("error", function(err) {
      debug("dgram error", err);
      // in node versions <= 0.12, the error event is emitted even when a callback is passed to send()
      // we always pass a callback to send(), so it's safe to do nothing here
    });
  }

  shutdown() {
    // eventually all messages will be processed and this queue will be empty
    // and then we can cleanly shutdown
    this.queue.empty = this._closeClient.bind(this);
  }

  forceShutdown() {
    this.queue.killAndDrain();
    this._closeClient();
  }

  send(message, callback = NOOP) {
    this.queue.push(message, callback);
  }
<commit_msg>rename variable<commit_after>/**
 * (C) 2013 Sazze, Inc.
 * MIT LICENCE
 *
 * Based on a gist by mbrevoort.
 * Available at: https://gist.github.com/mbrevoort/5848179
 *
 * Inspired by winston-logstash
 * Available at: https://github.com/jaakkos/winston-logstash
 */

// Really simple Winston Logstash UDP Logger

const dgram = require("dgram"),
  os = require("os"),
  winston = require("winston"),
  Transport = require("winston-transport"),
  fastq = require("fastq"),
  ReDNS = require("redns"),
  debug = require("debug")("winston-logstash-udp");

const { LEVEL } = require("triple-beam");

const NOOP = () => {};

const redns = new ReDNS();

class Sender {
  constructor(host, port) {
    this.host = host;
    this.port = port;
    this.client = null;

    this.queue = fastq(this, this._send, 1);
  }

  _connect() {
    this.client = dgram.createSocket({
      type: "udp4",
      lookup: redns.lookup.bind(r)
    });

    // Attach an error listener on the socket
    // It can also avoid top level exceptions like UDP DNS errors thrown by the socket
    this.client.on("error", function(err) {
      debug("dgram error", err);
      // in node versions <= 0.12, the error event is emitted even when a callback is passed to send()
      // we always pass a callback to send(), so it's safe to do nothing here
    });
  }

  shutdown() {
    // eventually all messages will be processed and this queue will be empty
    // and then we can cleanly shutdown
    this.queue.empty = this._closeClient.bind(this);
  }

  forceShutdown() {
    this.queue.killAndDrain();
    this._closeClient();
  }

  send(message, callback = NOOP) {
    this.queue.push(message, callback);
  }

{'fraction_non_alphanumeric': 0.13766388557806913, 'fraction_numerical': 0.009535160905840286, 'mean_word_length': 3.0251798561151078, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2379732', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1080, 'n_words': 321}