Overview

Namespaces

  • None
  • PHP
  • Pry
    • Auth
      • Interfaces
    • Config
    • Controller
    • Date
    • Db
    • Feed
      • Abstracts
      • Writers
    • File
      • Decorator
    • Form
      • Element
    • Image
    • Log
      • Writer
    • Net
      • Exception
    • Session
    • Util
    • Validate
      • Validator
    • View

Classes

  • Log
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: /**
 4:  * Pry Framework
 5:  *
 6:  * LICENSE
 7:  *
 8:  * This source file is subject to the new BSD license that is bundled
 9:  * with this package in the file LICENSE.txt.
10:  * 
11:  */
12: 
13: namespace Pry\Log;
14: 
15: /**
16:  *
17:  * Classe de gestion des Logs
18:  * @version 2.0.1
19:  * @author Olivier ROGER <oroger.fr>
20:  * @category Pry
21:  * @package Log
22:  */
23: class Log
24: {
25: 
26:     /**
27:      * Driver d'ecriture du log
28:      *
29:      * @var Log_Writer_Abstract
30:      */
31:     private $writer;
32:     private $severity = array();
33: 
34:     /**
35:      * Constructeur
36:      * @param Log_Writer_Abstract $writer
37:      */
38:     public function __construct($writer)
39:     {
40:         $this->writer   = $writer;
41:         $this->severity = array('emergency' => 0, 'alert' => 1, 'critical' => 2, 'error' => 3, 'warn' => 4, 'notice' => 5, 'info' => 6, 'debug' => 7);
42:     }
43: 
44:     /**
45:      * Surcharge de l'appel de fonction permettant de 
46:      * logguer des message avec les niveau en guise de methode.
47:      * Exemple $obj->info($message);
48:      *
49:      * @param string $method
50:      * @param array $param
51:      */
52:     public function __call($method, $param)
53:     {
54:         $method = strtolower($method);
55:         if (key_exists($method, $this->severity))
56:             $this->write(array_shift($param), $this->severity[$method]);
57:         else
58:             throw new \BadMethodCallException($method . ' est un niveau inconnu. Vous ne pouvez pas utiliser ' . $method . '()');
59:     }
60: 
61:     /**
62:      * Ecriture du log
63:      *
64:      * @param string $message
65:      * @param int $niveau
66:      */
67:     public function write($message, $niveau = 6)
68:     {
69:         $this->writer->write($message, $niveau);
70:     }
71: 
72: }
Pry API documentation generated by ApiGen 2.8.0