<commit_before>import { format } from 'util';

import { Logger, LoggerConfig } from '../types/logger';
import { DefaultLogger } from './default-logger';
import { Log } from './log';

describe('Log', () => {
  class LogMock extends Log {
    override bufferLogs = true;

    override moduleAlreadyImported(level: keyof Logger, ...args: any[]) {
      this.setLog(level, `${format(args[0])}, ${args[1]}`);
    }
  }

  let log: LogMock;

  beforeEach(() => {
    const config = new LoggerConfig();
    const logger = new DefaultLogger(config) as Logger;
    log = new LogMock(logger);
  });

  it('case 1', () => {
    expect(log.bufferLogs).toBe(true);
    expect(log.buffer).toEqual([]);
  });

  it('case 2', () => {
    class One {}
    log.moduleAlreadyImported('trace', One, 'two');
    expect(log.buffer).toEqual([['trace', '[class One], two']]);
    log.flush();
    expect(log.buffer).toEqual([]);
  });
});
<commit_msg>test(server): fixed Log tests<commit_after>import { format } from 'util';

import { Logger, LoggerConfig } from '../types/logger';
import { DefaultLogger } from './default-logger';
import { Log } from './log';

describe('Log', () => {
  class LogMock extends Log {
    override bufferLogs = true;

    override moduleAlreadyImported(level: keyof Logger, ...args: any[]) {
      this.setLog(level, `${format(args[0])}, ${args[1]}`);
    }
  }

  let log: LogMock;

  beforeEach(() => {
    const config = new LoggerConfig();
    const logger = new DefaultLogger(config) as Logger;
    log = new LogMock(logger);
  });

  it('case 1', () => {
    expect(log.bufferLogs).toBe(true);
    expect(log.buffer).toEqual([]);
  });

  it('case 2', () => {
    class One {}
    log.moduleAlreadyImported('trace', One, 'two');
    expect(log.buffer.length).toBe(1);
    expect(log.buffer[0].level).toEqual('trace');
    expect(log.buffer[0].msg).toEqual('[class One], two');
    log.flush();
    expect(log.buffer).toEqual([]);
  });
});

{'fraction_non_alphanumeric': 0.20225294418842807, 'fraction_numerical': 0.0056323604710701485, 'mean_word_length': 3.5231481481481484, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '510730', 'n_tokens_mistral': 637, 'n_tokens_neox': 627, 'n_words': 140}