delboy1978uk/bone-log

Log package for Bone Framework

v1.4.2 2024-05-06 15:44 UTC

This package is auto-updated.

Last update: 2024-12-06 17:12:46 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License
build status Code Coverage Scrutinizer Code Quality

Log package for Bone Framework

installation

bone-log is a core dependency of Bone Framework, as so comes installed as standard. See config/bone-log.php in the skeleton project

usage

To get a logger into your controllers, make them implement Bone\Log\LoggerAwareInterface, and use the trait Bone\Log\Traits\HasLoggerTrait.

<?php

namespace Whatever;

use Bone\Controller\Controller;
use Bone\Log\LoggerAwareInterface;
use Bone\Log\Traits\HasLoggerTrait;

class WhateverController extends Controller implements LoggerAwareInterface
{
    use HasLoggerTrait;

    // your code here
}

Then in your package registration class, pass your controller into Bone\Controller\Init::controller():

return  Init::controller(new WhateverController(), $c);

You can now call $this->getLogger(); and you will now have your PSR-3 logger at your disposal. See monolog/monolog for details.