Skip to content

Instantly share code, notes, and snippets.

@davidalger
Created June 2, 2020 22:43
Show Gist options
  • Save davidalger/5025914dcf482ec80972c7652d32bf9a to your computer and use it in GitHub Desktop.
Save davidalger/5025914dcf482ec80972c7652d32bf9a to your computer and use it in GitHub Desktop.
Prefixes logging output of Magento 2 database upgrade CLI commands with timestamp in HH:MM:SS format
--- webroot/vendor/magento/framework/Setup/ConsoleLogger.php 2020-06-02 17:09:24.000000000 -0500
+++ webroot/vendor/magento/framework/Setup/ConsoleLogger.php 2020-06-02 17:23:51.000000000 -0500
@@ -67,7 +67,7 @@
public function log($message)
{
$this->terminateLine();
- $this->console->writeln('<detail>' . $message . '</detail>');
+ $this->console->writeln('<detail>' . $this->logPrefix() . $message . '</detail>');
}
/**
@@ -76,7 +76,7 @@
public function logInline($message)
{
$this->isInline = true;
- $this->console->write('<detail>' . $message . '</detail>');
+ $this->console->write('<detail>' . $this->logPrefix() . $message . '</detail>');
}
/**
@@ -85,7 +85,7 @@
public function logMeta($message)
{
$this->terminateLine();
- $this->console->writeln('<metadata>' . $message . '</metadata>');
+ $this->console->writeln('<metadata>' . $this->logPrefix() . $message . '</metadata>');
}
/**
@@ -100,4 +100,9 @@
$this->console->writeln('');
}
}
+
+ private function logPrefix()
+ {
+ return '[' . date('H:i:s') . '] ';
+ }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment