17 private LoggerInterface $logger;
20 private const CHANNEL_NAME =
'Translate.Jobs';
26 private function getLogger(): LoggerInterface {
27 $this->logger ??= LoggerFactory::getInstance( self::CHANNEL_NAME );
32 private function formatLogEntry(
string $msg, array $context = [] ): array {
33 $prefix = $this->getType();
34 if ( isset( $this->title ) ) {
35 $prefix .=
' [{job_title}]';
36 $context[
'job_title'] = $this->title->getPrefixedText();
39 return [
"$prefix: $msg", $context ];
42 protected function logDebug(
string $msg, array $context = [] ):
void {
43 [ $msg, $context ] = $this->formatLogEntry( $msg, $context );
44 $this->getLogger()->debug( $msg, $context );
47 protected function logInfo(
string $msg, array $context = [] ):
void {
48 [ $msg, $context ] = $this->formatLogEntry( $msg, $context );
49 $this->getLogger()->info( $msg, $context );
52 protected function logNotice(
string $msg, array $context = [] ):
void {
53 [ $msg, $context ] = $this->formatLogEntry( $msg, $context );
54 $this->getLogger()->notice( $msg, $context );
57 protected function logWarning(
string $msg, array $context = [] ):
void {
58 [ $msg, $context ] = $this->formatLogEntry( $msg, $context );
59 $this->getLogger()->warning( $msg, $context );
62 protected function logError(
string $msg, array $context = [] ):
void {
63 [ $msg, $context ] = $this->formatLogEntry( $msg, $context );
64 $this->getLogger()->error( $msg, $context );