1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11:
12:
13: namespace Pry\Log;
14:
15: 16: 17: 18: 19: 20: 21: 22:
23: class Log
24: {
25:
26: 27: 28: 29: 30:
31: private $writer;
32: private $severity = array();
33:
34: 35: 36: 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: 46: 47: 48: 49: 50: 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: 63: 64: 65: 66:
67: public function write($message, $niveau = 6)
68: {
69: $this->writer->write($message, $niveau);
70: }
71:
72: }