<commit_before>/* eslint-env mocha */
'use strict';
const Winston = require('winston');

describe('logging', () => {
  it('returns a WINSTON object', () => {
    const config = require('../lib/config');
    const log = require('../lib/logger').attach(config);

    log.should.be.an.instanceOf(Winston.Logger);
  });
});<commit_msg>Updated tests to make sure log level and filename are correctly set.<commit_after>/* eslint-env mocha */
'use strict';

require('should');
const fs = require('fs');
const Winston = require('winston');

class ConfigLike {
  constructor() {
    this.data = {
      'log:level': 'info',
      'log:filename': 'tmp.log'
    };
  }

  get(str) {
    return this.data[str];
  }
}

describe('Logging', () => {
  const config = new ConfigLike();
  const log = require('../lib/logger').attach(config);
  const configFile = config.get('log:filename');

  it('returns a WINSTON object', () => {
    log.should.be.an.instanceOf(Winston.Logger);
  });

  it('sets the log level correctly', () => {
    log.level.should.be.exactly('info');
  });

  before((done) => {
    log.log(config.get('log:level'), 'Test logging message');
    done();
  });

  it('writes to the correct file', (done) => {
    fs.readFileSync(configFile, 'utf8').should.not.be.Error; // eslint-disable-line no-unused-expressions
    fs.unlinkSync(configFile);
    done();
  });
});
{'fraction_non_alphanumeric': 0.19912472647702406, 'fraction_numerical': 0.0007293946024799417, 'mean_word_length': 3.5733333333333333, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, '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': '863535', 'n_tokens_mistral': 464, 'n_tokens_neox': 448, 'n_words': 94}