Log = require '../../src/util/log'

describe 'Log', ->
  it 'shoud log debug messages', (done)   -> testDebug(done);
  it 'shoud log info messages', (done)    -> testInfo(done);
  it 'shoud log warning messages', (done) -> testWarn(done);
  it 'shoud log error messages', (done)   -> testError(done);
  
  afterEach ->
    Log.logtoConsole = false;
    Log.clearLoggers();
  beforeEach ->
    assert = require 'assert'
    Log.logtoConsole=false
    Log.addLogger log:(msg)-> 
      assert msg.match(/\[\d+-\d+-\d+ \d+:\d+:\d+\] (INFO|DEBUG|WARN|ERROR): Testing$/), "Unexpected message"

testDebug = (callback)-> Log.debug('Testing'); callback()
testInfo = (callback)->  Log.info('Testing');callback()
testWarn = (callback)->  Log.warn('Testing');callback()
testError = (callback)-> Log.error('Testing');callback()