1: <?php
2: /**
3: * Pry Framework
4: *
5: * LICENSE
6: *
7: * This source file is subject to the new BSD license that is bundled
8: * with this package in the file LICENSE.txt.
9: *
10: * @version $Revision: 276 $
11: */
12:
13: /**
14: *
15: * Classe de gestion des Logs
16: * @version 2.0.1
17: * @author Olivier ROGER <oroger.fr>
18: * @category Pry
19: * @package Log
20: *
21: *
22: */
23: class Log_Log
24: {
25: /**
26: * Driver d'ecriture du log
27: *
28: * @var Log_Writer_Abstract
29: */
30: private $writer;
31:
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: ?>