<commit_before>'use strict'

describe('Logging interface', function () {
  var PORT = 6242
  var flags = ['--user', 'derek', '--pass', '<PASSWORD>']
  var authUrl = 'nats://derek:foobar@localhost:' + PORT
  var server

  // Start up our own nats-server
  before(function (done) {
    server = HemeraTestsuite.start_server(PORT, flags, done)
  })

  // Shutdown our server after we are done
  after(function () {
    server.kill()
  })

  it('Should be able to use custom logger', function (done) {
    const nats = require('nats').connect(authUrl)

    let logger = {
      info: function () {},
      fatal: function () {}
    }

    var logSpy = Sinon.spy(logger, 'info')

    const hemera = new Hemera(nats, {
      logger
    })

    hemera.ready(() => {
      hemera.add({
        topic: 'math',
        cmd: 'add'
      }, (resp, cb) => {
        cb(null, {
          result: resp.a + resp.b
        })
      })

      hemera.act({
        topic: 'math',
        cmd: 'add',
        a: 1,
        b: 2
      }, (err, resp) => {
        expect(err).to.be.not.exists()
        expect(resp).not.to.be.equals(3)
        expect(logSpy.called).to.be.equals(true)
        hemera.close()
        done()
      })
    })
  })
})<commit_msg>test default logger with real output<commit_after>'use strict'

describe('Logging interface', function () {
  var PORT = 6242
  var flags = ['--user', 'derek', '--pass', '<PASSWORD>']
  var authUrl = 'nats://derek:foobar@localhost:' + PORT
  var server

  // Start up our own nats-server
  before(function (done) {
    server = HemeraTestsuite.start_server(PORT, flags, done)
  })

  // Shutdown our server after we are done
  after(function () {
    server.kill()
  })

  it('Should be able to use custom logger', function (done) {
    const nats = require('nats').connect(authUrl)

    let logger = {
      info: function () {},
      fatal: function () {}
    }

    var logSpy = Sinon.spy(logger, 'info')

    const hemera = new Hemera(nats, {
      logger
    })

    hemera.ready(() => {
      hemera.add({
        topic: 'math',
        cmd: 'add'
      }, (resp, cb) => {
        cb(null, {
          result: resp.a + resp.b
        })
      })

      hemera.act({
        topic: 'math',
        cmd: 'add',
        a: 1,
        b: 2
      }, (err, resp) => {
        expect(err).to.be.not.exists()
        expect(resp).not.to.be.equals(3)
        expect(logSpy.called).to.be.equals(true)
        hemera.close()
        done()
      })
    })
  })

  it('Should be able to log with default logger', function (done) {
    const nats = require('nats').connect(authUrl)
    const hemera = new Hemera(nats, {
      logLevel: 'info'
    })

    hemera.ready(() => {
      hemera.add({
        topic: 'math',
        cmd: 'add'
      }, (resp, cb) => {
        cb(null, {
          result: resp.a + resp.b
        })
      })

      hemera.act({
        topic: 'math',
        cmd: 'add',
        a: 1,
        b: 2
      }, (err, resp) => {
        expect(err).to.be.not.exists()
        expect(resp).not.to.be.equals(3)
        hemera.close()
        done()
      })
    })
  })
})
{'fraction_non_alphanumeric': 0.16688020499679693, 'fraction_numerical': 0.005445227418321589, 'mean_word_length': 1.8809963099630995, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '4411793', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1051, 'n_words': 241}