<?php
namespace App\Logger; class FluxInstance extends \App\Logger\TINALogger { static protected $instance; private $fluxInstance = null; static public function getInstance() { if (!static::$instance) { $class = __CLASS__; if (!$class) { throw new \Exception("Default Logger not configured"); } static::$instance = new $class(); static::$instance->setLogSession(\Log::getInstance()->getLogSession(true)); } return static::$instance; } public function writeRawMessage($fields) { $fields['source'] = ($fields['source']?:'FluxInstance'); $fluXIdentifier = "undefined"; if ($fields['context']['fluxInstance']) { $fluXIdentifier = sprintf("%s #%s", $fields['context']['fluxInstance']->name, $fields['context']['fluxInstance']->getId()); unset($fields['context']['fluxInstance']); } elseif ($this->fluxInstance) { $fluXIdentifier = sprintf("%s #%s", $this->fluxInstance->name, $this->fluxInstance->getId()); } $fields['message'].= " [FluX:{$fluXIdentifier}]"; if ($fields['context']['file']) { $fields['message'].= " [File:{$fields['context']['file']->getFilename()}]"; } parent::writeRawMessage($fields); } public function setFluXInstance($fluxInstance) { $this->fluxInstance = $fluxInstance; return $this; } } 