\donbidon\Core\LogT_Logger

Logger trait.

See API index page for "config.php".

class Foo
{
    use \donbidon\Core\Log\T_Logger;

    public function __construct(\donbidon\Core\Registry\I_Registry $registry)
    {
        $this->evtManager = $registry->get('core/event/manager');
        // $this->evtManager = \donbidon\Core\Registry\Recursive::_get(
        //    'core/event/manager'
        // );
    }

    public function someMethod()
    {
        $this->log("Notice",  'Foo::someMethod()', E_NOTICE);
        $this->log("Warning", 'Foo::someMethod()', E_WARNING);
        $this->log("Error",   'Foo::someMethod()', E_ERROR);
    }

    public function otherMethod()
    {
        $this->log("Warning from other method",  'Foo::otherMethod()', E_WARNING);
    }
}

$registry = \donbidon\Core\Bootstrap::initByPath("/path/to/config.php");

$foo = new Foo($registry);
echo
"Now will be echoed notices/warnings/errors only from 'Foo::someMethod()' source:",
PHP_EOL;
$foo->someMethod();
$foo->otherMethod();
$registry->delete('core/log/E_ALL/level');

echo
PHP_EOL,
"Now will be echoed warnings/errors (default level) only from 'Foo::someMethod()' source:",
PHP_EOL;
$foo->someMethod();

echo
PHP_EOL,
"Now will be echoed warnings/errors from all sources:",
PHP_EOL;
$source = $registry->get('core/log/E_ALL/source');
$source[] = "*";
$registry->set('core/log/E_ALL/source', $source);
$foo->someMethod();
$foo->otherMethod();

outputs

Now will be echoed notices/warnings/errors only from 'Foo::someMethod()' source:
[ YYYY-MM-DD **:**:** ] [ note ] [ Foo::someMethod() ] ~ Notice
[ YYYY-MM-DD **:**:** ] [ WARN ] [ Foo::someMethod() ] ~ Warning
[ YYYY-MM-DD **:**:** ] [ ERR  ] [ Foo::someMethod() ] ~ Error

Now will be echoed warnings/errors (default level) only from 'Foo::someMethod()' source:
[ YYYY-MM-DD **:**:** ] [ WARN ] [ Foo::someMethod() ] ~ Warning
[ YYYY-MM-DD **:**:** ] [ ERR  ] [ Foo::someMethod() ] ~ Error

Now will be echoed warnings/errors from all sources:
[ YYYY-MM-DD **:**:** ] [ WARN ] [ Foo::someMethod() ] ~ Warning
[ YYYY-MM-DD **:**:** ] [ ERR  ] [ Foo::someMethod() ] ~ Error
[ YYYY-MM-DD **:**:** ] [ WARN ] [ Foo::otherMethod() ] ~ Warning from other method

Summary

Methods
Properties
Constants
No public methods found
No public properties found
No constants found
log()
$evtManager
N/A
No private methods found
No private properties found
N/A

Properties

Methods

log()

log(string  $message, string  $source = null, integer  $level = E_NOTICE, mixed  $data = null) : void

Fires event to log message.

Parameters

string $message
string $source
integer $level
mixed $data

Exception data

Throws

\donbidon\Core\ExceptionExtended

If no event manager present.