1 | <?php |
||
3 | final class GravityView_Logging { |
||
4 | |||
5 | private static $errors = array(); |
||
6 | private static $notices = array(); |
||
7 | |||
8 | function __construct() { |
||
21 | |||
22 | /** |
||
23 | * Add integration with the Debug Bar plugin. It's awesome. |
||
24 | * |
||
25 | * @see http://wordpress.org/plugins/debug-bar/ |
||
26 | */ |
||
27 | public function add_debug_bar( $panels ) { |
||
41 | |||
42 | /** |
||
43 | * Enables debug with Gravity Forms logging add-on |
||
44 | * @param array $supported_plugins List of plugins |
||
45 | */ |
||
46 | public function enable_gform_logging( $supported_plugins ) { |
||
50 | |||
51 | /** |
||
52 | * @static |
||
53 | * @return array Array of notices (with `message`, `data`, and `backtrace` keys), if any |
||
54 | */ |
||
55 | public static function get_notices() { |
||
58 | |||
59 | /** |
||
60 | * @static |
||
61 | * @return array Array of errors (with `message`, `data`, and `backtrace` keys), if any |
||
62 | */ |
||
63 | public static function get_errors() { |
||
66 | |||
67 | /** |
||
68 | * Get the name of the function to print messages for debugging |
||
69 | * |
||
70 | * This is necessary because `ob_start()` doesn't allow `print_r()` inside it. |
||
71 | * |
||
72 | * @return string "print_r" or "var_export" |
||
73 | */ |
||
74 | 3 | static function get_print_function() { |
|
83 | |||
84 | 3 | static function log_debug( $message = '', $data = null ) { |
|
102 | |||
103 | static function log_error( $message = '', $data = null ) { |
||
123 | |||
124 | } |
||
125 | |||
126 | new GravityView_Logging; |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.