File:
0.00.1a/core/LoggingEngine.php (
View as Code)
1: 2: /* -------------------------------------------------------------
3: This file is part of FreeDESK
4:
5: FreeDESK is (C) Copyright 2012 David Cutting
6:
7: FreeDESK is free software: you can redistribute it and/or modify
8: it under the terms of the GNU General Public License as published by
9: the Free Software Foundation, either version 3 of the License, or
10: (at your option) any later version.
11:
12: FreeDESK is distributed in the hope that it will be useful,
13: but WITHOUT ANY WARRANTY; without even the implied warranty of
14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: GNU General Public License for more details.
16:
17: You should have received a copy of the GNU General Public License
18: along with FreeDESK. If not, see www.gnu.org/licenses
19:
20: For more information see www.purplepixie.org/freedesk/
21: -------------------------------------------------------------- */
22:
23: /**
24: * LoggingEngine class - handles all the logging events for the system
25: **/
26: class LoggingEngine
27: {
28: /**
29: * FreeDESK instance
30: **/
31: private $DESK = null;
32: /**
33: * Logging Level
34: **/
35: private $loglevel = 10;
36: /**
37: * Concrete Methods
38: **/
39: private $methods = array();
40: /**
41: * Configured types
42: **/
43: private $types = array();
44:
45: /**
46: * Constructor
47: * @param mixed $freeDESK FreeDESK instance
48: **/
49: function LoggingEngine(&$freeDESK)
50: {
51: $this->DESK=&$freeDESK;
52: $this->DESK->Include->IncludeFile("core/LogMethodBase.php");
53: $this->DESK->PluginManager->Register(new Plugin(
54: "Logging Engine", "0.01", "Core" ));
55:
56: // Now we include the shipped standard logging method(s)
57: $this->methods['LogMethodDB'] = $this->DESK->Include->IncludeInstance("core/logging/LogMethodDB.php","LogMethodDB");
58: }
59:
60: /**
61: * Start logging engine
62: **/
63: function Start()
64: {
65: $this->loglevel = $this->DESK->Configuration->Get("log.level",10);
66:
67:
68: // And get a list of the currently configured logging options
69: $logopts = $this->DESK->Configuration->Get("log.types","LogMethodDB");
70: $logopts = explode(":",$logopts);
71:
72: // Now set the required logging methods
73: foreach($logopts as $logtype)
74: {
75: if (isset($this->methods[$logtype])) // Does it exist?
76: $this->types[] = $logtype;
77: }
78: }
79:
80: /**
81: * Log an event
82: * @param string $event Event description
83: * @param string $class Event class
84: * @param string $type Event type (optional, default "")
85: * @param int $level Event level (0 = fatal, 10 = low priority info only) (optional, default 10)
86: **/
87: function Log($event, $class, $type="", $level=10)
88: {
89: if ($level > $this->loglevel) // Ignore
90: return false;
91: foreach($this->types as $method)
92: $this->methods[$method]->Log($event, $class, $type, $level);
93: }
94:
95: }
96:
97:
98: ?>
99: