mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-09-08 14:15:40 +08:00
updated logging
This commit is contained in:
parent
5532071fc5
commit
df3d3391bd
7 changed files with 88 additions and 16 deletions
|
@ -63,12 +63,25 @@ function authenticate(connection, token, callback) {
|
|||
password
|
||||
}, connection.session, (err, response) => {
|
||||
if (err) {
|
||||
connection._server.logger.info('[%s] Authentication error for %s using %s\n%s', connection.id, username, 'PLAIN', err.message);
|
||||
connection._server.logger.info({
|
||||
err,
|
||||
tnx: 'auth',
|
||||
username,
|
||||
method: 'PLAIN',
|
||||
action: 'fail',
|
||||
cid: connection.id
|
||||
}, '[%s] Authentication error for %s using %s\n%s', connection.id, username, 'PLAIN', err.message);
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!response || !response.user) {
|
||||
connection._server.logger.info('[%s] Authentication failed for %s using %s', connection.id, username, 'PLAIN');
|
||||
connection._server.logger.info({
|
||||
tnx: 'auth',
|
||||
username,
|
||||
method: 'PLAIN',
|
||||
action: 'fail',
|
||||
cid: connection.id
|
||||
}, '[%s] Authentication failed for %s using %s', connection.id, username, 'PLAIN');
|
||||
return callback(null, {
|
||||
response: 'NO',
|
||||
code: 'AUTHENTICATIONFAILED',
|
||||
|
@ -76,7 +89,13 @@ function authenticate(connection, token, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
connection._server.logger.info('[%s] %s authenticated using %s', connection.id, username, 'PLAIN');
|
||||
connection._server.logger.info({
|
||||
tnx: 'auth',
|
||||
username,
|
||||
method: 'PLAIN',
|
||||
action: 'success',
|
||||
cid: connection.id
|
||||
}, '[%s] %s authenticated using %s', connection.id, username, 'PLAIN');
|
||||
connection.session.user = response.user;
|
||||
connection.state = 'Authenticated';
|
||||
|
||||
|
|
|
@ -38,12 +38,20 @@ module.exports = {
|
|||
this._inflate = zlib.createInflateRaw();
|
||||
|
||||
this._deflate.once('error', err => {
|
||||
this._server.logger.debug('[%s] Deflate error %s', this.id, err.message);
|
||||
this._server.logger.debug({
|
||||
err,
|
||||
tnx: 'deflate',
|
||||
cid: this.id
|
||||
}, '[%s] Deflate error %s', this.id, err.message);
|
||||
this.close();
|
||||
});
|
||||
|
||||
this._inflate.once('error', err => {
|
||||
this._server.logger.debug('[%s] Inflate error %s', this.id, err.message);
|
||||
this._server.logger.debug({
|
||||
err,
|
||||
tnx: 'inflate',
|
||||
cid: this.id
|
||||
}, '[%s] Inflate error %s', this.id, err.message);
|
||||
this.close();
|
||||
});
|
||||
|
||||
|
@ -59,6 +67,7 @@ module.exports = {
|
|||
return this._deflate.once('drain', readNext);
|
||||
}
|
||||
}
|
||||
|
||||
// flush data to socket
|
||||
if (this._deflate) {
|
||||
this._deflate.flush();
|
||||
|
|
|
@ -221,10 +221,13 @@ module.exports = {
|
|||
query.push(item);
|
||||
}
|
||||
|
||||
this._server.logger.debug('[%s] FETCH: %s', this.id, JSON.stringify({
|
||||
this._server.logger.debug({
|
||||
tnx: 'fetch',
|
||||
cid: this.id
|
||||
}, '[%s] FETCH: %s', this.id, JSON.stringify({
|
||||
metadataOnly: !!metadataOnly,
|
||||
markAsSeen: !!markAsSeen,
|
||||
messages:messages.length,
|
||||
messages: messages.length,
|
||||
query,
|
||||
changedSince,
|
||||
isUid
|
||||
|
|
|
@ -41,12 +41,18 @@ module.exports = {
|
|||
}
|
||||
});
|
||||
|
||||
this._server.logger.info('[%s] Client identification data received', this.id);
|
||||
this._server.logger.info({
|
||||
tnx: 'id',
|
||||
cid: this.id
|
||||
}, '[%s] Client identification data received', this.id);
|
||||
|
||||
Object.keys(clientId).
|
||||
sort((a, b) => (allowedKeys.indexOf(a) - allowedKeys.indexOf(b))).
|
||||
forEach(key => {
|
||||
this._server.logger.info('[%s] %s%s: %s', this.id, key, new Array(maxKeyLen - key.length + 1).join(' '), clientId[key]);
|
||||
this._server.logger.info({
|
||||
tnx: 'id',
|
||||
cid: this.id
|
||||
}, '[%s] %s%s: %s', this.id, key, new Array(maxKeyLen - key.length + 1).join(' '), clientId[key]);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,13 @@ module.exports = {
|
|||
|
||||
// Check if authentication method is set
|
||||
if (typeof this._server.onAuth !== 'function') {
|
||||
this._server.logger.info('[%s] Authentication failed for %s using %s', this.id, username, 'LOGIN');
|
||||
this._server.logger.info({
|
||||
tnx: 'auth',
|
||||
username,
|
||||
method: 'LOGIN',
|
||||
action: 'fail',
|
||||
cid: this.id
|
||||
}, '[%s] Authentication failed for %s using %s', this.id, username, 'LOGIN');
|
||||
return callback(null, {
|
||||
response: 'NO',
|
||||
message: 'Authentication not implemented'
|
||||
|
@ -44,12 +50,25 @@ module.exports = {
|
|||
if (err.response) {
|
||||
return callback(null, err);
|
||||
}
|
||||
this._server.logger.info('[%s] Authentication error for %s using %s\n%s', this.id, username, 'LOGIN', err.message);
|
||||
this._server.logger.info({
|
||||
err,
|
||||
tnx: 'auth',
|
||||
username,
|
||||
method: 'LOGIN',
|
||||
action: 'fail',
|
||||
cid: this.id
|
||||
}, '[%s] Authentication error for %s using %s\n%s', this.id, username, 'LOGIN', err.message);
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!response || !response.user) {
|
||||
this._server.logger.info('[%s] Authentication failed for %s using %s', this.id, username, 'LOGIN');
|
||||
this._server.logger.info({
|
||||
tnx: 'auth',
|
||||
username,
|
||||
method: 'LOGIN',
|
||||
action: 'fail',
|
||||
cid: this.id
|
||||
}, '[%s] Authentication failed for %s using %s', this.id, username, 'LOGIN');
|
||||
return callback(null, {
|
||||
response: 'NO',
|
||||
code: 'AUTHENTICATIONFAILED',
|
||||
|
@ -57,7 +76,13 @@ module.exports = {
|
|||
});
|
||||
}
|
||||
|
||||
this._server.logger.info('[%s] %s authenticated using %s', this.id, username, 'LOGIN');
|
||||
this._server.logger.info({
|
||||
tnx: 'auth',
|
||||
username,
|
||||
method: 'LOGIN',
|
||||
action: 'success',
|
||||
cid: this.id
|
||||
}, '[%s] %s authenticated using %s', this.id, username, 'LOGIN');
|
||||
this.session.user = response.user;
|
||||
this.state = 'Authenticated';
|
||||
|
||||
|
|
|
@ -63,7 +63,10 @@ function upgrade(connection) {
|
|||
connection._socket = secureSocket;
|
||||
connection._upgrading = false;
|
||||
|
||||
connection._server.logger.info('[%s] Connection upgraded to TLS', connection.id);
|
||||
connection._server.logger.info({
|
||||
tnx: 'starttls',
|
||||
cid: connection.id
|
||||
}, '[%s] Connection upgraded to TLS', connection.id);
|
||||
connection._socket.pipe(connection._parser);
|
||||
connection.writeStream.pipe(connection._socket);
|
||||
});
|
||||
|
|
|
@ -20,7 +20,10 @@ class IMAPComposer extends Transform {
|
|||
|
||||
if (typeof obj.pipe === 'function') {
|
||||
// pipe stream to socket and wait until it finishes before continuing
|
||||
this.connection._server.logger.debug('[%s] S: %s<pipe message stream to socket>', this.connection.id, obj.description || '');
|
||||
this.connection._server.logger.debug({
|
||||
tnx: 'pipeout',
|
||||
cid: this.connection.id
|
||||
}, '[%s] S: %s<pipe message stream to socket>', this.connection.id, obj.description || '');
|
||||
obj.pipe(this.connection[!this.connection.compression ? '_socket' : '_deflate'], {
|
||||
end: false
|
||||
});
|
||||
|
@ -34,7 +37,11 @@ class IMAPComposer extends Transform {
|
|||
|
||||
let compiled = imapHandler.compiler(obj);
|
||||
|
||||
this.connection._server.logger.debug('[%s] S:', this.connection.id, compiled);
|
||||
this.connection._server.logger.debug({
|
||||
tnx: 'send',
|
||||
cid: this.connection.id
|
||||
}, '[%s] S:', this.connection.id, compiled);
|
||||
|
||||
this.push(new Buffer(compiled + '\r\n', 'binary'));
|
||||
done();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue