2017 © Pedro Peláez
 

library logging

image

fliglio/logging

  • Friday, March 2, 2018
  • by benschw
  • Repository
  • 2 Watchers
  • 0 Stars
  • 1,926 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 15 % Grown

The README.md

Build Status Latest Stable Version, (*1)

Fliglio.Logging

Run tests using:, (*2)

$ make test

supplies the \Fliglio\Logging\FLog trait to add in a psr compatible log() method., (*3)

Configure with monolog, (*4)

$ composer require monolog/monolog

//index.php
$logger = new Logger("Demo");¬
$handler = new StreamHandler('php://stderr');¬
$logger->pushHandler($handler);¬

FLogRegistry::set(new FLogger($logger , new FLogContext()));

Configure with KLogger, (*5)

$ composer require katzgrau/klogger

//index.php
$logger = new \Katzgrau\KLogger\Logger('php://stderr');

FLogRegistry::set(new FLogger($logger , new FLogContext()));

Use in a class (with the trait), (*6)

class Demo {
    use FLog;

    public function __construct() {
        $this->log()->info("hello constructor!");
    }

    public function doATask($taskType) {
        $this->log()->context()->add("taskType", $taskType);
        $this->log()->info("Starting Task");
        foreach (["a", "b", "c", "d"] as $subTask) {
            $this->log()->context()->add("subTask", $subTask);
            $this->log()->info("Starting SubTask");

            try {
                doWork();
                $this->log()->info("SubTask Completed!");
            } catch (\Exception $e) {
                $this->log()->warning("SubtTask Problem!", ["e" => $e]);

            }
        }
        $this->log()->context()->remove("subTask");
        $this->log()->info("SubtTask Completed!");
        $this->log()->context()->remove("taskType");
    }
}


$logger = new \Katzgrau\KLogger\Logger('php://stderr');
$flogger = new FLogger($logger , new FLogContext()));
FLogRegistry::set($flogger);


$flogger->info("Starting...");

$demo = new Demo();
$demo->doATask("Foo");

$flogger->info("Ending...");

Output:, (*7)

[2019-10-04 20:25:28.001557] [info] Starting...
[2019-10-04 20:25:28.001606] [info] hello constructor!
[2019-10-04 20:25:28.001641] [info] Starting Task
    taskType: 'Foo'
[2019-10-04 20:25:28.001688] [info] Starting SubTask
    taskType: 'Foo'
    subTask: 'a'
[2019-10-04 20:25:28.001739] [info] SubTask Completed!
    taskType: 'Foo'
    subTask: 'a'
[2019-10-04 20:25:28.001780] [info] Starting SubTask
    taskType: 'Foo'
    subTask: 'b'
[2019-10-04 20:25:28.001821] [info] SubTask Completed!
    taskType: 'Foo'
    subTask: 'b'
[2019-10-04 20:25:28.001862] [info] Starting SubTask
    taskType: 'Foo'
    subTask: 'c'
[2019-10-04 20:25:28.001902] [info] SubTask Completed!
    taskType: 'Foo'
    subTask: 'c'
[2019-10-04 20:25:28.001945] [info] Starting SubTask
    taskType: 'Foo'
    subTask: 'd'
[2019-10-04 20:25:28.001985] [info] SubTask Completed!
    taskType: 'Foo'
    subTask: 'd'
[2019-10-04 20:25:28.002028] [info] SubtTask Completed!
    taskType: 'Foo'
[2019-10-04 20:25:28.002070] [info] Ending...

The Versions

02/03 2018

dev-master

9999999-dev

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Ben Schwartz

02/03 2018

v2.1.1

2.1.1.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Ben Schwartz

22/10 2016

v2.1.0

2.1.0.0

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Ben Schwartz

22/10 2016

dev-tests

dev-tests

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Ben Schwartz

21/10 2016

dev-psr

dev-psr

  Sources   Download

GPL-3.0+

The Requires

 

The Development Requires

by Ben Schwartz