<commit_before>import { WinstonLoggerAdapter } from 'parse-server/lib/Adapters/Logger/WinstonLoggerAdapter';
const WinstonFirehose = require('winston-firehose');

const DEFAULT_REGION = 'us-east-1';

export class FirehoseLoggerAdapter extends WinstonLoggerAdapter {
  constructor(...args) {
    super(args);
    const options = this.optionsFromArguments(args);

    if (process.env.NODE_ENV !== 'test') {
      const transport = new WinstonFirehose(options);
      this.addTransport(transport);
    }
  }

  // following three functions copied from s3Adapter.  Would be nice to have a lib...
  requiredOrFromEnvironment(options, key, env) {
    options[key] = options[key] || process.env[env]; // eslint-disable-line no-param-reassign

    if (!options[key]) {
      throw new Error(`FirehoseLoggerAdapter requires option '${key}' or env. variable ${env}`);
    }
    return options;
  }

  fromEnvironmentOrDefault(options, key, env, defaultValue) {
    // eslint-disable-next-line no-param-reassign
    options[key] = options[key] || process.env[env] || defaultValue;
    return options;
  }

  optionsFromArguments(args) {
    let options = {};
    const streamNameOrOptions = args[0];
    if (typeof streamNameOrOptions === 'string') {
      options.streamName = streamNameOrOptions;
    } else {
      options = streamNameOrOptions || {};
    }
    options = this.requiredOrFromEnvironment(options, 'streamName', 'FIREHOSE_LOGGER_STREAM_NAME');

    let firehoseOptions = options.firehoseOptions || {};
    firehoseOptions = this.fromEnvironmentOrDefault(
      firehoseOptions, 'region', 'FIREHOSE_LOGGER_REGION', DEFAULT_REGION);
    firehoseOptions = this.fromEnvironmentOrDefault(
      firehoseOptions, 'level', 'FIREHOSE_LOGGER_LEVEL', '');
    options.firehoseOptions = firehoseOptions;

    return options;
  }
}

export default FirehoseLoggerAdapter;
module.exports = FirehoseLoggerAdapter;<commit_msg>Reorder deck chairs, i mean exports. Don't think it matters<commit_after>import { WinstonLoggerAdapter } from 'parse-server/lib/Adapters/Logger/WinstonLoggerAdapter';
const WinstonFirehose = require('winston-firehose');

const DEFAULT_REGION = 'us-east-1';

export class FirehoseLoggerAdapter extends WinstonLoggerAdapter {
  constructor(...args) {
    super(args);
    const options = this.optionsFromArguments(args);

    if (process.env.NODE_ENV !== 'test') {
      const transport = new WinstonFirehose(options);
      this.addTransport(transport);
    }
  }

  // following three functions copied from s3Adapter.  Would be nice to have a lib...
  requiredOrFromEnvironment(options, key, env) {
    options[key] = options[key] || process.env[env]; // eslint-disable-line no-param-reassign

    if (!options[key]) {
      throw new Error(`FirehoseLoggerAdapter requires option '${key}' or env. variable ${env}`);
    }
    return options;
  }

  fromEnvironmentOrDefault(options, key, env, defaultValue) {
    // eslint-disable-next-line no-param-reassign
    options[key] = options[key] || process.env[env] || defaultValue;
    return options;
  }

  optionsFromArguments(args) {
    let options = {};
    const streamNameOrOptions = args[0];
    if (typeof streamNameOrOptions === 'string') {
      options.streamName = streamNameOrOptions;
    } else {
      options = streamNameOrOptions || {};
    }
    options = this.requiredOrFromEnvironment(options, 'streamName', 'FIREHOSE_LOGGER_STREAM_NAME');

    let firehoseOptions = options.firehoseOptions || {};
    firehoseOptions = this.fromEnvironmentOrDefault(
      firehoseOptions, 'region', 'FIREHOSE_LOGGER_REGION', DEFAULT_REGION);
    firehoseOptions = this.fromEnvironmentOrDefault(
      firehoseOptions, 'level', 'FIREHOSE_LOGGER_LEVEL', '');
    options.firehoseOptions = firehoseOptions;

    return options;
  }
}

module.exports = FirehoseLoggerAdapter;
export default FirehoseLoggerAdapter;
{'fraction_non_alphanumeric': 0.11681279009798866, 'fraction_numerical': 0.0015471892728210418, 'mean_word_length': 4.1789052069425905, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, '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': '1049924', 'n_tokens_mistral': 1171, 'n_tokens_neox': 1146, 'n_words': 242}