2017 © Pedro Peláez
 

symfony-bundle logger-bundle

Symfony bundle for logging actions

image

domtomproject/logger-bundle

Symfony bundle for logging actions

  • Tuesday, July 18, 2017
  • by DomTomProject
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

LoggerBundle

Bundle for fast loggin and static storage, (*1)

1. Installation

 composer require domtomproject/logger-bundle

AND in AppKernel.php, (*2)

$bundles = [
...
  new DomTomProject\LoggerBundle\DomtomLoggerBundle(),
...
];

2. Configuration

In this example we use MysqlWriter. In config.yml, (*3)

...
doctrine:
    dbal:
        default_connection: default
        connections:
            ...
            log:
                driver:   pdo_mysql
                host:     '%database_host%'
                port:     '%database_port%'
                dbname:   'database'
                user:     '%database_user%'
                password: '%database_password%'
                charset:  UTF8
...
orm:
   ...
   entity_managers:
     log:
        connection: log
        mappings:
            AppBundle: ~
...
domtom_logger:
    writer: "domtom_logger.writer_mysql"
    mysql:
        manager: log

So now manager for logs is 'log'. Thats provide you to use other database for log data., (*4)

3. Using Example

a) Create new Log Entity.

use Doctrine\ORM\Mapping as ORM;
use DomTomProject\LoggerBundle\Model\Log;

/**
 * @ORM\Entity
 */
class CustomLog extends Log {

    /**
     * @Column(type="text", nullable=true)
     */
    protected $text;

    public function __construct() {
        parent::__construct();
    }

    // method for short creating in one line 
    public static function create(?string $text = null){
       $log = new self();
       $log->setText($text);
       return $log;
    }

    // setters and getters ...

}

b) Now in controller action

   public function testLogAction(){
      $logStack = $this->get('domtom_logger.log_stack');
      $logStack->add(CustomLog::create('Log that'));
      ....

      // if something failed you can check all logs in stack as failed. Its done automatically if kernel.exception event is called.
      if($somethingBroken){
         $logStack->failed();
      }

   }

c) Logs will be automatically saved on kernel.terminate event.

The Versions

18/07 2017

dev-master

9999999-dev

Symfony bundle for logging actions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Zschille

logging debugging

20/06 2017

1.0

1.0.0.0

Symfony bundle for logging actions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Zschille

logging debugging

12/06 2017

0.95

0.95.0.0

Symfony bundle for logging actions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Zschille

logging debugging

08/06 2017

0.9

0.9.0.0

Symfony bundle for logging actions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Damian Zschille

logging debugging