mirror of
https://github.com/log4js-node/log4js-node.git
synced 2025-12-08 19:26:01 +00:00
Module loading solution
This commit is contained in:
parent
436782b614
commit
338c5fc77d
@ -2,8 +2,7 @@
|
||||
var layouts = require('../layouts');
|
||||
var layout;
|
||||
var config;
|
||||
var mailgun = require('mailgun-js');
|
||||
|
||||
var mailgun;
|
||||
|
||||
function mailgunAppender(_config, _layout) {
|
||||
|
||||
@ -17,11 +16,11 @@ function mailgunAppender(_config, _layout) {
|
||||
to: _config.to,
|
||||
subject: _config.subject,
|
||||
text: layout(loggingEvent, config.timezoneOffset)
|
||||
};
|
||||
}
|
||||
|
||||
mailgun.messages().send(data, function (error, body) {
|
||||
if (error != null) console.error('log4js.mailgunAppender - Error happened', error);
|
||||
});
|
||||
console.log(body);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@ -32,8 +31,10 @@ function configure(_config) {
|
||||
layout = layouts.layout(_config.layout.type, _config.layout);
|
||||
}
|
||||
|
||||
mailgun.apiKey = config.apikey;
|
||||
mailgun.domain = config.domain;
|
||||
mailgun = require('mailgun-js')({
|
||||
apiKey: _config.apikey,
|
||||
domain: _config.domain
|
||||
});
|
||||
|
||||
return mailgunAppender(_config, layout);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user