Skip to content

Commit 09a535d

Browse files
committed
ZMS-19: add levels to GELF logs, remove full_message on less important error logs
1 parent 21b5b98 commit 09a535d

1 file changed

Lines changed: 24 additions & 9 deletions

File tree

index.js

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ exports.handle_forwarding_address = async function (connection, address, address
241241
} catch (err) {
242242
// failed checks
243243
err.resolution = {
244-
full_message: err.stack,
244+
_stack: err.stack,
245+
level: 4,
245246
_forward: 'yes',
246247
_rate_limit: 'yes',
247248
_selector: 'user',
@@ -674,7 +675,8 @@ exports.real_rcpt_handler = function (next, connection, params) {
674675
} catch (err) {
675676
connection.logerror(plugin, 'SRS FAILED rcpt=' + address + ' error=' + err.message);
676677
resolution = {
677-
full_message: err.stack,
678+
_stack: err.stack,
679+
level: 5,
678680
_srs: 'yes',
679681

680682
_failure: 'yes',
@@ -692,7 +694,8 @@ exports.real_rcpt_handler = function (next, connection, params) {
692694
return plugin.checkRateLimit(connection, selector, key, false, (err, success) => {
693695
if (err) {
694696
resolution = {
695-
full_message: err.stack,
697+
_stack: err.stack,
698+
level: 4,
696699
_srs: 'yes',
697700
_rate_limit: 'yes',
698701
_selector: selector,
@@ -745,7 +748,8 @@ exports.real_rcpt_handler = function (next, connection, params) {
745748
plugin.checkRateLimit(connection, selector, key, false, (err, success) => {
746749
if (err) {
747750
resolution = {
748-
full_message: err.stack,
751+
_stack: err.stack,
752+
level: 4,
749753
_rate_limit: 'yes',
750754
_selector: selector,
751755
_user: userData._id.toString(),
@@ -797,6 +801,7 @@ exports.real_rcpt_handler = function (next, connection, params) {
797801
if (err) {
798802
resolution = {
799803
full_message: err.stack,
804+
level: 3,
800805
_api: 'resolveAddress',
801806
_db_query: 'address:' + address,
802807

@@ -868,6 +873,7 @@ exports.real_rcpt_handler = function (next, connection, params) {
868873
if (err) {
869874
resolution = {
870875
full_message: err.stack,
876+
level: 3,
871877
_api: 'getUser',
872878
_db_query: 'user:' + addressData.user,
873879

@@ -922,7 +928,8 @@ exports.real_rcpt_handler = function (next, connection, params) {
922928
plugin.checkRateLimit(connection, selector, key, userData.receivedMax, (err, success) => {
923929
if (err) {
924930
resolution = {
925-
full_message: err.stack,
931+
_stack: err.stack,
932+
level: 4,
926933
_rate_limit: 'yes',
927934
_selector: selector,
928935
_user: userData._id.toString(),
@@ -980,7 +987,8 @@ exports.real_rcpt_handler = function (next, connection, params) {
980987
plugin.db.users.collection('domaincache').findOne({ domain: addressDomain }, { projection: { _id: 1 } }, (err, data) => {
981988
if (err) {
982989
resolution = {
983-
full_message: err.stack,
990+
_stack: err.stack,
991+
level: 4,
984992
_api: 'getDomaincache',
985993
_db_query: 'domain:' + addressDomain,
986994

@@ -1150,6 +1158,7 @@ exports.hook_queue = function (next, connection) {
11501158
connection.logerror(plugin, 'PIPEFAIL error=' + err.message);
11511159
sendLogEntry({
11521160
full_message: err.stack,
1161+
level: 3,
11531162
_error: 'pipefail processing input',
11541163
_failure: 'yes',
11551164
_err_code: err.code
@@ -1242,7 +1251,8 @@ exports.hook_queue = function (next, connection) {
12421251
err.code = err.code || 'ERRCOMPOSE';
12431252
sendLogEntry({
12441253
short_message: '[Failed forward] ' + queueId,
1245-
full_message: err.stack,
1254+
_stack: err.stack,
1255+
level: 4,
12461256

12471257
_error: 'failed to store message',
12481258
_mail_action: 'forward',
@@ -1293,7 +1303,8 @@ exports.hook_queue = function (next, connection) {
12931303
message.once('error', err => {
12941304
connection.logerror(plugin, 'QUEUEERROR Failed to retrieve message. error=' + err.message);
12951305
sendLogEntry({
1296-
full_message: err.stack,
1306+
_stack: err.stack,
1307+
level: 4,
12971308

12981309
_error: 'failed to retrieve message from input',
12991310
_failure: 'yes',
@@ -1584,7 +1595,8 @@ exports.hook_queue = function (next, connection) {
15841595

15851596
if (response.error.code === 'DroppedByPolicy') {
15861597
sendLogEntry({
1587-
full_message: response.error.message,
1598+
_stack: response.error.message,
1599+
level: 6,
15881600

15891601
_user: userData._id.toString(),
15901602
_to: recipient,
@@ -1607,6 +1619,7 @@ exports.hook_queue = function (next, connection) {
16071619
} else {
16081620
sendLogEntry({
16091621
full_message: response.error.stack,
1622+
level: 3,
16101623

16111624
_user: userData._id.toString(),
16121625
_to: recipient,
@@ -1651,6 +1664,7 @@ exports.hook_queue = function (next, connection) {
16511664
} catch (err) {
16521665
sendLogEntry({
16531666
full_message: err.stack,
1667+
level: 2,
16541668

16551669
_user: userData._id.toString(),
16561670
_address: recipient,
@@ -1705,6 +1719,7 @@ exports.hook_queue = function (next, connection) {
17051719
} catch (err) {
17061720
sendLogEntry({
17071721
full_message: err.stack,
1722+
level: 2,
17081723
_no_store: 'yes',
17091724
_error: 'failed to store message',
17101725
_failure: 'yes',

0 commit comments

Comments
 (0)