Highway to PSR2
[openemr.git] / portal / patient / fwk / libs / verysimple / DB / Reflection / DBEventHandler.php
bloba315c5877019cf297c13e548a7aebd395a95448c
1 <?php
2 /** @package verysimple::DB::Reflection */
4 /**
5 * import supporting libraries
6 */
7 require_once('verysimple/DB/DatabaseException.php');
9 define("DBH_LOG_NONE", 1);
10 define("DBH_LOG_INFO", 2);
11 define("DBH_LOG_DEBUG", 4);
12 define("DBH_LOG_QUERY", 8);
13 define("DBH_LOG_WARNING", 16);
14 define("DBH_LOG_ERROR", 32);
16 /**
17 * DBEventHandler is an optional parameter that can be used to hook into events in the
18 * DAO system for intercepting, debugging and observing
20 * @package verysimple::DB::Reflection
21 * @author Jason Hinkle
22 * @copyright 1997-2007 VerySimple, Inc.
23 * @license http://www.gnu.org/licenses/lgpl.html LGPL
24 * @version 1.0
26 class DBEventHandler
28 public $LogLevel;
29 function __construct($level = DBH_LOG_NONE)
31 $this->LogLevel = $level;
34 /**
35 * Called by DB objects to report logging information
37 * @access public
38 * @param int $level
39 * @param string $message
40 * @param string $data
42 function Log($level, $message, $data = "")
44 $data = $data != "" ? ": $data" : "";
45 switch ($level) {
46 case DBH_LOG_DEBUG:
47 if ($this->LogLevel & DBH_LOG_DEBUG) {
48 print "<pre style='color: silver;'>$message</pre>\r\n";
50 break;
51 case DBH_LOG_INFO:
52 if ($this->LogLevel & DBH_LOG_INFO) {
53 print "<pre style='color: blue;'>$message $data</pre>\r\n";
55 break;
56 case DBH_LOG_QUERY:
57 if ($this->LogLevel & DBH_LOG_QUERY) {
58 print "<pre style='color: green;'>$message $data</pre>\r\n";
60 break;
61 case DBH_LOG_WARNING:
62 if ($this->LogLevel & DBH_LOG_WARNING) {
63 print "<pre style='color: orange;'>$message $data</pre>\r\n";
65 break;
66 case DBH_LOG_ERROR:
67 if ($this->LogLevel & DBH_LOG_ERROR) {
68 print "<pre style='color: red;'>$message $data</pre>\r\n";
70 break;
74 /**
75 * Called by DB objects when a critical error occurs
77 * @access public
78 * @param int $code
79 * unique numerical identifier for error
80 * @param string $message
81 * human-readable error
82 * @param string $data
83 * any additional information that may help with debugging
85 function Crash($code, $message = "", $data = "")
87 throw new DatabaseException($message, $code, $data);