I have my helper where I want to implement my override logger. The logger work perfect outside the helper but I can't make it work inside the helper:
namespace Acme\Module\Helper; class Data extends \Magento\Framework\App\Helper\AbstractHelper { protected $_logger; public function __construct( \Acme\Module\Logger\Logger $logger ) { $this->_logger = $logger; } public function setLogger($message, $context = info) { $this->_logger->info("y pues anda daleeeeeeeeeeeeeeeeeeeee"); } But looks like the whay i am injecting the logger class it is not the correct way to do it. I just get a 500 error so I think it is a problem in the way i am injecting the class into the helper.
=====================================================================
Edited
I manage to avoid the injection error adding a context in the construct but now my class is not overriding the logger as it should:
class Data extends \Magento\Framework\App\Helper\AbstractHelper { protected $httpHeader; protected $mobileAgent; public function __construct( \Acme\Module\Logger\Logger $logger, \Magento\Framework\App\Helper\Context $context ) { $this->_logger = $logger; parent::__construct($context); } public function setLogger($message, $context = false) { $this->_logger->info("y pues anda ooooooooooo"); } I also found out that the context can get the folowing methods in the helper:
$context->getRequest(); // return \Magento\Framework\App\RequestInterface $context->getUrlBuilder(); // return \Magento\Framework\UrlInterface $context->getScopeConfig(); // return \Magento\Framework\App\Config\ScopeConfigInterface $context->getLogger(); // return \Psr\Log\LoggerInterface $context->getEventManager(); // return \Magento\Framework\Event\ManagerInterface $context->getModuleManager(); // return \Magento\Framework\Module\Manager $context->getCacheConfig(); // return \Magento\Framework\Cache\ConfigInterface $context->getHttpHeader(); // return \Magento\Framework\HTTP\Header $context->getRemoteAddress(); // return \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $context->getUrlEncoder(); // return \Magento\Framework\Url\EncoderInterface $context->getUrlDecoder(); // return \Magento\Framework\Url\DecoderInterface