<commit_before>path = require 'path'
should = require('chai').should()


describe '[log]', ->

  before -> global.__nocolor = true
  after -> global.__nocolor = null && delete global.__nocolor

  afterEach ->
    global.__stdout = global.__stderr = null
    delete global.__stdout
    delete global.__stderr

  it 'error', (done)->
    msgs = [
      'error Hello world'
      'error Hello world 1'
      'error Hello world 1 2'
    ]

    global.__stderr = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length

    {error} = require('../../../lib/utils/logger')()
    error 'Hello world'
    error 'Hello world', 1
    error 'Hello world', 1, 2
    
  it 'warn', (done)->
    msgs = [
      'warn Hello world'
      'warn Hello world 1'
      'warn Hello world 1 2'
    ]

    global.__stderr = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length
    
    {warn} = require('../../../lib/utils/logger')()
    warn 'Hello world'
    warn 'Hello world', 1
    warn 'Hello world', 1, 2  

  it 'info', (done)->
    msgs = [
      'info Hello world'
      'info Hello world 1'
      'info Hello world 1 2'
    ]

    global.__stdout = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length<commit_msg>Testing logger with colors enabled<commit_after>path = require 'path'
should = require('chai').should()

require 'colors'

describe '[log]', ->

  before -> global.__nocolor = true
  after -> global.__nocolor = null && delete global.__nocolor

  afterEach ->
    global.__stdout = global.__stderr = null
    delete global.__stdout
    delete global.__stderr

  it 'error', (done)->
    msgs = [
      'error Hello world'
      'error Hello world 1'
      'error Hello world 1 2'
    ]

    global.__stderr = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length

    {error} = require('../../../lib/utils/logger')()
    error 'Hello world'
    error 'Hello world', 1
    error 'Hello world', 1, 2
  
  it 'error with colors', (done)->
    msgs = [
      "#{'error'.bold.red} #{'Hello world'.grey}"
      "#{'error'.bold.red} #{'Hello world'.grey} 1"
      "#{'error'.bold.red} #{'Hello world'.grey} 1 2"
    ]

    global.__stderr = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length

    global.__nocolor = false

    {error} = require('../../../lib/utils/logger')()
    error 'Hello world'
    error 'Hello world', 1
    error 'Hello world', 1, 2

    global.__nocolor = true

  it 'warn', (done)->
    msgs = [
      'warn Hello world'
      'warn Hello world 1'
      'warn Hello world 1 2'
    ]

    global.__stderr = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length
    
    {warn} = require('../../../lib/utils/logger')()
    warn 'Hello world'
    warn 'Hello world', 1
    warn 'Hello world', 1, 2  

  it 'warn with colors', (done)->
    msgs = [
      "#{'warn'.bold.yellow} #{'Hello world'.grey}"
      "#{'warn'.bold.yellow} #{'Hello world'.grey} 1"
      "#{'warn'.bold.yellow} #{'Hello world'.grey} 1 2"
    ]

    global.__stderr = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length

    global.__nocolor = false

    delete global.__nocolor
    {warn} = require('../../../lib/utils/logger')()
    warn 'Hello world'
    warn 'Hello world', 1
    warn 'Hello world', 1, 2

    global.__nocolor = true

  it 'info', (done)->
    msgs = [
      'info Hello world'
      'info Hello world 1'
      'info Hello world 1 2'
    ]

    global.__stdout = (data)->
      data.should.equal msgs.shift()
      done() unless msgs.length
{'fraction_non_alphanumeric': 0.16109422492401215, 'fraction_numerical': 0.01160541586073501, 'mean_word_length': 2.2263814616755795, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, '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': '3197952', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1144, 'n_words': 333}