GLOBAL.projRequire = function (module) {
	return require('../' + module);
};

const log = projRequire('lib');
const tc = require('test-console');
const test = require('tape');

log.setMinLogLevel('debug');

test('log.debug() prints correctly', function (t) {
	const err = tc.stdout.inspectSync(function () {
		log.debug('test_error');
	});

	t.equals(err[0], 'debug:{"code":"test_error"}\n');
	t.end();
});

test('log.info() prints correctly', function (t) {
	const err = tc.stdout.inspectSync(function () {
		log.info('test_error');
	});

	t.equals(err[0], 'info:{"code":"test_error"}\n');
	t.end();
});

test('log.warn() prints correctly', function (t) {
	const err = tc.stderr.inspectSync(function () {
		log.warn('test_error');
	});

	t.equals(err[0], 'warn:{"code":"test_error"}\n');
	t.end();
});

test('log.error() prints correctly', function (t) {
	const err = tc.stderr.inspectSync(function () {
		log.error('test_error');
	});

	t.equals(err[0], 'error:{"code":"test_error"}\n');
	t.end();
});

test('log prints JSON correctly', function (t) {
	const err = tc.stderr.inspectSync(function () {
		log.error('test_error', { a: 'b', c: 'd' });
	});

	t.equals(err[0], 'error:{"code":"test_error","meta":{"a":"b","c":"d"}}\n');
	t.end();
});

@@ -339,41 +339,192 @@
 ;%0A%0A%09
-t.equals(err%5B0%5D, 'debug:%7B%22
+const obj = JSON.parse(err%5B0%5D);%0A%0A%09t.equals(obj._level, 'debug');%0A%09t.assert(obj._timestamp);%0A%09t.equals(obj._git_commit, 'dev');%0A%09t.equals(obj._service, 'unknown');%0A%09t.equals(obj.
 code
-%22:%22
+, '
 test
@@ -521,37 +521,56 @@
 ode, 'test_error
-%22%7D%5Cn'
+');%0A%09t.assert(!obj.stack
 );%0A%09t.end();%0A%7D);
@@ -708,55 +708,225 @@
 ;%0A%0A%09
-t.equals(err%5B0%5D, 'info:%7B%22code%22:%22test_error%22%7D%5Cn'
+const obj = JSON.parse(err%5B0%5D);%0A%0A%09t.equals(obj._level, 'info');%0A%09t.assert(obj._timestamp);%0A%09t.equals(obj._git_commit, 'dev');%0A%09t.equals(obj._service, 'unknown');%0A%09t.equals(obj.code, 'test_error');%0A%09t.assert(!obj.stack
 );%0A%09
@@ -1001,35 +1001,35 @@
 nst err = tc.std
-err
+out
 .inspectSync(fun
@@ -1076,40 +1076,191 @@
 ;%0A%0A%09
-t.equals(err%5B0%5D, 'warn:%7B%22
+const obj = JSON.parse(err%5B0%5D);%0A%0A%09t.equals(obj._level, 'warn');%0A%09t.assert(obj._timestamp);%0A%09t.equals(obj._git_commit, 'dev');%0A%09t.equals(obj._service, 'unknown');%0A%09t.equals(obj.
 code
-%22:%22
+, '
 test
@@ -1257,37 +1257,56 @@
 ode, 'test_error
-%22%7D%5Cn'
+');%0A%09t.assert(!obj.stack
 );%0A%09t.end();%0A%7D);
@@ -1446,41 +1446,192 @@
 ;%0A%0A%09
-t.equals(err%5B0%5D, 'error:%7B%22code%22:%22
+const obj = JSON.parse(err%5B0%5D);%0A%0A%09t.equals(obj._level, 'error');%0A%09t.assert(obj._timestamp);%0A%09t.equals(obj._git_commit, 'dev');%0A%09t.equals(obj._service, 'unknown');%0A%09t.equals(obj.code, '
 test
@@ -1640,16 +1640,34 @@
 rror
-%22%7D%5Cn
 ');%0A
+%09t.assert(obj.stack);%0A
 %09t.e
@@ -1833,81 +1833,281 @@
 ;%0A%0A%09
-t.equals(err%5B0%5D, 'error:%7B%22code%22:%22test_error%22,%22meta%22:%7B%22a%22:%22b%22,%22c%22:%22d%22%7D%7D%5Cn'
+const obj = JSON.parse(err%5B0%5D);%0A%0A%09t.equals(obj._level, 'error');%0A%09t.assert(obj._timestamp);%0A%09t.equals(obj._git_commit, 'dev');%0A%09t.equals(obj._service, 'unknown');%0A%09t.equals(obj.code, 'test_error');%0A%09t.equals(obj.meta.a, 'b');%0A%09t.equals(obj.meta.c, 'd');%0A%09t.assert(obj.stack
 );%0A%09

fix tests