1 | var path = require('path');
|
2 | var notifier = null;
|
3 | try {
|
4 | notifier = require('node-notifier');
|
5 | } catch (error) {
|
6 | notifier = null;
|
7 | }
|
8 |
|
9 | function icon(level) {
|
10 | return path.resolve(__dirname, '../icons/node_' + level + '.png');
|
11 | }
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | module.exports = function (cfg, log) {
|
17 | return function (title, msg, level) {
|
18 | level = level || 'info';
|
19 | log([title, msg].filter(_ => _).join(': '), level);
|
20 | if (notifier !== null && cfg.notify) {
|
21 | notifier.notify({
|
22 | title: title || 'node.js',
|
23 | icon: icon(level),
|
24 | message: msg
|
25 | });
|
26 | }
|
27 | };
|
28 | };
|