Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Avatar for KuCalc : devops.
Download
50660 views
1
/*
2
* log-test.js: Tests for the broadway logger plugin
3
*
4
* (C) 2011, Nodejitsu Inc.
5
* MIT LICENSE
6
*
7
*/
8
9
var vows = require('vows'),
10
events = require('eventemitter2'),
11
assert = require('../helpers/assert'),
12
helpers = require('../helpers/helpers'),
13
macros = require('../helpers/macros'),
14
broadway = require('../../lib/broadway');
15
16
var app = helpers.mockApp();
17
app.options = {
18
log: {
19
logAll: true,
20
namespaces: {
21
'apps': 'foo'
22
}
23
}
24
};
25
26
vows.describe('broadway/plugins/log').addBatch({
27
"Using the log plugin": {
28
"to extend an application": macros.shouldExtend(app, 'log', {
29
"when the application emits log::# events": macros.shouldLogEvent(app, [
30
'log::warn',
31
'some warn message',
32
{ foo: 'bar' }
33
], assert.log.msgMeta)
34
}),
35
"when the application emits log::#::# events": macros.shouldLogEvent(app, [
36
'log::warn::some-category',
37
'some warn message',
38
{ foo: 'bar' }
39
], assert.log.msgMeta),
40
"when the application emits log events with": {
41
"message and meta": macros.shouldLogEvent(app, [
42
'log',
43
'some info message',
44
{ foo: 'bar' },
45
], assert.log.msgMeta),
46
"level and message": macros.shouldLogEvent(app, [
47
'log',
48
'silly',
49
'some silly message',
50
], assert.log.levelMsg),
51
"level and meta": macros.shouldLogEvent(app, [
52
'log',
53
'info',
54
{ foo: 'bar' },
55
], assert.log.levelMeta)
56
},
57
"when the application emits namespaced events with": {
58
"level and meta": macros.shouldLogEvent(app, [
59
'apps::start',
60
'info',
61
{ foo: 'bar' },
62
], assert.log.levelMeta),
63
"meta only": macros.shouldLogEvent(app, [
64
'apps::start',
65
{ foo: 'bar' },
66
], assert.log.metaOnly)
67
}
68
}
69
}).export(module);
70