var assert = require('assert'),
    vows = require('vows'),
    winston = require('winston'),
    nssocket = require('nssocket'),
    macros = require('./helpers/macros'),
    ns = require('../');

vows.describe('winston-nssocket').addBatch({
  'When using `winston-nssocket`': {
    topic: function () {
      var logger = new winston.Logger({
        transports: [
          new ns.NsSocket({ host: '127.0.0.1', port: 1234 })
        ]
      });

      nssocket.createServer(this.callback.bind(this, null, logger)).listen(1234);
    },
    'it should send logs to `nssocket` server': {
      'with no meta': macros.log('info', 'hello world!'),
      'with meta': macros.log('error', 'hello world!', { chill: 'winston!' })
    }
  }
}).export(module);

@@ -1,12 +1,47 @@
+/**%0A * winston-nssocket tests%0A */%0A%0A
 var assert =
@@ -227,87 +227,112 @@
 ./')
-;%0A%0Avows.describe('winston-nssocket').addBatch(%7B%0A  'When using %60
+,%0A    winstond = require('winstond');%0A%0A//%0A// winstond nssocket server%0A//%0A%0Avar server = 
 winston
--
+d.
 nssocket
 %60': 
@@ -331,45 +331,209 @@
 cket
-%60': %7B%0A    topic: function () %7B%0A      
+.createServer(%7B%0A  services: %5B'collect', 'query', 'stream'%5D,%0A  port: 1234%0A%7D);%0A%0Aserver.add(winstond.transports.File, %7B%0A  filename: __dirname + '/test.log'%0A%7D);%0A%0Aserver.listen();%0A%0A//%0A// winston logger%0A//%0A%0A
 var 
@@ -562,22 +562,16 @@
 ogger(%7B%0A
-      
   transp
@@ -578,22 +578,16 @@
 orts: %5B%0A
-      
     new 
@@ -591,17 +591,17 @@
 ew ns.Ns
-S
+s
 ocket(%7B 
@@ -611,17 +611,17 @@
 t: '
-127.0.0.1
+localhost
 ', p
@@ -639,109 +639,622 @@
 )%0A  
-      %5D%0A      %7D);%0A%0A      nssocket.createServer(this.callback.bind(this, null, logger)).listen(1234
+%5D%0A%7D);%0A%0A//%0A// tests%0A//%0A%0Avows.describe('winston-nssocket').addBatch(%7B%0A  'When using %60winston-nssocket%60': %7B%0A    'topic': logger,%0A    'the log() method': %7B%0A      'topic': function() %7B%0A        logger.log('info', 'hello world', %7B%7D, this.callback);%0A      %7D,%0A      'should respond with true': function (err, logged) %7B%0A        assert.isNull(err);%0A        assert.isNotNull(logged);%0A      %7D%0A    %7D,%0A    'the query() method': %7B%0A      'topic': function (logger) %7B%0A        var cb = this.callback;%0A        logger.log('info', 'hello world', %7B%7D);%0A        setTimeout(function () %7B%0A          logger.query(%7B%7D, cb);%0A        %7D, 1000
 );%0A
+  
     
@@ -1264,189 +1264,1080 @@
     
-'it 
+  '
 should 
-send logs to %60nssocket%60 server': %7B%0A      'with no meta': macros.log('info', 'hello world!'),%0A      'with meta': macros.log('error', 'hello world!', %7B chill: 'winston!' %7D)
+return matching results': function (err, results) %7B%0A        results = results.nssocket.file;%0A        var log = results.pop();%0A        assert.ok(log.message.indexOf('hello world') === 0%0A                  %7C%7C log.message.indexOf('test message') === 0);%0A      %7D%0A    %7D,%0A    'the stream() method': %7B%0A      'topic': function () %7B%0A        logger.log('info', 'hello world', %7B%7D);%0A%0A        var cb = this.callback,%0A            j = 10,%0A            i = 10,%0A            results = %5B%5D,%0A            stream = logger.stream(%7B%7D);%0A%0A        stream.on('log', function (log) %7B%0A          results.push(log);%0A          results.stream = stream;%0A          if (!--j) cb(null, results);%0A        %7D);%0A%0A        stream.on('error', function () %7B%7D);%0A%0A        while (i--) logger.log('info', 'hello world ' + i, %7B%7D);%0A      %7D,%0A      'should stream logs': function (err, results) %7B%0A        results.forEach(function (log) %7B%0A          assert.ok(log.message.indexOf('hello world') === 0%0A                    %7C%7C log.message.indexOf('test message') === 0);%0A        %7D);%0A        results.stream.destroy();%0A      %7D
 %0A   

add querying and streaming tests.