Update log messages

This commit is contained in:
Visman 2021-01-24 13:25:22 +07:00
parent 688dbb1764
commit a780e3cd66
6 changed files with 28 additions and 23 deletions

View file

@ -24,7 +24,7 @@ class Auth extends Page
public function logout(array $args): Page
{
if (! $this->c->Csrf->verify($args['token'], 'Logout', $args)) {
$this->c->Log->warning('Logout failed', [
$this->c->Log->warning('Logout: fail', [
'user' => $this->user->fLog(),
]);
@ -35,7 +35,7 @@ class Auth extends Page
$this->c->Online->delete($this->user);
$this->c->users->updateLastVisit($this->user);
$this->c->Log->info('Logout', [
$this->c->Log->info('Logout: ok', [
'user' => $this->user->fLog(),
]);
@ -79,7 +79,7 @@ class Auth extends Page
$this->fIswev = $v->getErrors();
$this->c->Log->warning('Login failed', [
$this->c->Log->warning('Login: fail', [
'user' => $this->user->fLog(),
'form' => $v->getData(false, ['token', 'password']),
]);
@ -120,7 +120,7 @@ class Auth extends Page
$this->c->Online->delete($this->user);
$this->c->Cookie->setUser($this->userAfterLogin, (bool) $v->save);
$this->c->Log->info('Login', [
$this->c->Log->info('Login: ok', [
'user' => $this->userAfterLogin->fLog(),
'form' => $v->getData(false, ['token', 'password']),
'headers' => true,
@ -267,8 +267,9 @@ class Auth extends Page
} catch (MailException $e) {
$isSent = false;
$this->c->Log->error('Passphrase reset form MailException', $context + [
$this->c->Log->error('Passphrase reset: form, MailException', [
'exception' => $e,
'headers' => false,
]);
}
@ -278,7 +279,7 @@ class Auth extends Page
$this->c->users->update($tmpUser);
$this->c->Log->info('Passphrase reset form ok', $context);
$this->c->Log->info('Passphrase reset: form, ok', $context);
return $this->c->Message->message(__('Forget mail', $this->c->config->o_admin_email), false, 200);
} else {
@ -288,7 +289,7 @@ class Auth extends Page
$this->fIswev = $v->getErrors();
$this->c->Log->warning('Passphrase reset form failed', $context);
$this->c->Log->warning('Passphrase reset: form, fail', $context);
}
$this->hhsLevel = 'secure';
@ -352,7 +353,7 @@ class Auth extends Page
|| empty($user->activate_string)
|| ! \hash_equals($user->activate_string, $args['key'])
) {
$this->c->Log->warning('Passphrase reset confirmation failed', [
$this->c->Log->warning('Passphrase reset: confirmation, fail', [
'user' => $user instanceof User ? $user->fLog() : $this->user->fLog(),
'args' => $args,
]);
@ -392,7 +393,7 @@ class Auth extends Page
$this->fIswev = ['s', __('Pass updated')];
$this->c->Log->info('Passphrase updated', [
$this->c->Log->info('Passphrase reset: ok', [
'user' => $user->fLog(),
]);
@ -401,7 +402,7 @@ class Auth extends Page
$this->fIswev = $v->getErrors();
$this->c->Log->warning('Passphrase change form failed', [
$this->c->Log->warning('Passphrase reset: change form, fail', [
'user' => $user->fLog(),
'form' => $v->getData(false, ['token', 'password', 'password2']),
]);
@ -415,7 +416,7 @@ class Auth extends Page
$this->fIswev = ['i', __('Account activated')];
$this->c->Log->info('Account activated', [
$this->c->Log->info('Account activation: ok', [
'user' => $user->fLog(),
]);
}

View file

@ -92,7 +92,7 @@ class Email extends Page
$this->c->users->update($this->user);
}
$this->c->Log->info('Email sent', [
$this->c->Log->info('Email send: ok', [
'user' => $this->user->fLog(),
'recipient' => $this->curUser->fLog(),
]);
@ -100,7 +100,7 @@ class Email extends Page
return $this->c->Redirect->url($v->redirect)->message('Email sent redirect');
}
} catch (MailException $e) {
$this->c->Log->error('Email send MailException', [
$this->c->Log->error('Email send: MailException', [
'user' => $this->user->fLog(),
'exception' => $e,
'headers' => false,
@ -113,7 +113,7 @@ class Email extends Page
$this->fIswev = $v->getErrors();
$data = $v->getData();
$this->c->Log->warning('Email send form failed', [
$this->c->Log->warning('Email send: form, fail', [
'user' => $this->user->fLog(),
'recipient' => $this->curUser->fLog(),
]);

View file

@ -130,6 +130,11 @@ class Email extends Profile
->send();
} catch (MailException $e) {
$isSent = false;
$this->c->Log->error('Email activation: MailException', [
'exception' => $e,
'headers' => false,
]);
}
if ($isSent) {

View file

@ -59,7 +59,7 @@ class Register extends Page
$this->fIswev = $v->getErrors();
$this->c->Log->warning('Registration failed', [
$this->c->Log->warning('Registration: fail', [
'user' => $this->user->fLog(),
'form' => $v->getData(false, ['token', 'password']),
]);
@ -170,7 +170,7 @@ class Register extends Page
$newUserId = $this->c->users->insert($user);
$this->c->Log->info('Registriaton', [
$this->c->Log->info('Registriaton: ok', [
'user' => $user->fLog(),
'form' => $v->getData(false, ['token', 'password']),
'headers' => true,
@ -208,8 +208,7 @@ class Register extends Page
->setTpl('new_user.tpl', $tplData)
->send();
} catch (MailException $e) {
$this->c->Log->error('Registration notification to admins MailException', [
'user' => $user->fLog(),
$this->c->Log->error('Registration: notification to admins, MailException', [
'exception' => $e,
'headers' => false,
]);
@ -249,7 +248,7 @@ class Register extends Page
->setTpl('welcome.tpl', $tplData)
->send();
} catch (MailException $e) {
$this->c->Log->error('Registration activation email MailException', [
$this->c->Log->error('Registration: MailException', [
'user' => $user->fLog(),
'exception' => $e,
'headers' => false,
@ -287,7 +286,7 @@ class Register extends Page
|| empty($user->activate_string)
|| ! \hash_equals($user->activate_string, $args['key'])
) {
$this->c->Log->warning('Account activation failed', [
$this->c->Log->warning('Account activation: fail', [
'user' => $user instanceof User ? $user->fLog() : $this->user->fLog(),
'args' => $args,
]);
@ -301,7 +300,7 @@ class Register extends Page
$this->c->users->update($user);
$this->c->Log->info('Account activated', [
$this->c->Log->info('Account activation: ok', [
'user' => $user->fLog(),
]);

View file

@ -77,7 +77,7 @@ class Report extends Page
} catch (MailException $e) {
$result = false;
$this->c->Log->error('Report send MailException', [
$this->c->Log->error('Report: MailException', [
'user' => $this->user->fLog(),
'exception' => $e,
'headers' => false,

View file

@ -159,7 +159,7 @@ class Send extends Method
$this->c->Lang->load('common', $this->c->user->language);
} catch (MailException $e) {
$this->c->Log->error('Subscription send MailException', [
$this->c->Log->error('Subscription: MailException', [
'exception' => $e,
'headers' => false,
]);