New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log in file every level of message #91

Merged
merged 3 commits into from Jun 29, 2018

Conversation

Projects
None yet
2 participants
@Quetzacoalt91
Member

Quetzacoalt91 commented Jun 28, 2018

  • Add everything in logs: messages, errors ...
  • Add date & time before entries
[28-06-18 19:45:24] Starting upgrade...
[28-06-18 19:45:24] Shop deactivated. Now downloading... (this can take a while)
[28-06-18 19:45:24] Downloaded archive will come from https://download.prestashop.com/download/releases/prestashop_1.7.3.4.zip
[28-06-18 19:45:24] MD5 hash will be checked against ce0a59d7816e97d080a1fbb84e566a7b
[28-06-18 19:45:25] Downloading from https://download.prestashop.com/download/releases/prestashop_1.7.3.4.zip
[28-06-18 19:45:25] File will be saved in /var/www/html/admin-dev/autoupgrade/download/prestashop.zip
[28-06-18 19:45:25] Download directory has been emptied

@Quetzacoalt91 Quetzacoalt91 added this to the 4.0.0 milestone Jun 28, 2018

@@ -89,6 +89,10 @@ public function log($level, $message, array $context = array())
return;
}
if (!empty($this->fd)) {

This comment has been minimized.

@PierreRambaud

PierreRambaud Jun 29, 2018

Contributor

Should it be is_resource instead of empty?

This comment has been minimized.

@Quetzacoalt91

Quetzacoalt91 Jun 29, 2018

Member

No, I had a case where fopen calls could return false or null (for instance when it was forbidden), that's why I chose this test.

This comment has been minimized.

@PierreRambaud

PierreRambaud Jun 29, 2018

Contributor

But is_resource on null or false will return false when fwrite / fopen need a resource :p

This comment has been minimized.

@Quetzacoalt91

Quetzacoalt91 Jun 29, 2018

Member

... indeed 😆

@@ -89,6 +89,10 @@ public function log($level, $message, array $context = array())
return;
}
if (!empty($this->fd)) {
fwrite($this->fd, '[' . date('d-m-y H:i:s') . '] ' . $message . PHP_EOL);

This comment has been minimized.

@PierreRambaud

PierreRambaud Jun 29, 2018

Contributor

Better to write date like Y-m-d H:i:s for syslog and other logs parser tools

This comment has been minimized.

@Quetzacoalt91

Quetzacoalt91 Jun 29, 2018

Member

Here you go!

@Quetzacoalt91 Quetzacoalt91 merged commit f377a55 into PrestaShop:dev Jun 29, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment