Created
December 8, 2015 19:51
-
-
Save clsource/ba10c6ea770e520b24bc to your computer and use it in GitHub Desktop.
Processwire Debug Helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Copyright (c) 2015 - CLSource | |
* Helps with the debug log. | |
* see: https://processwire.com/talk/topic/4550-debugging-tips/ | |
* | |
* @author : clsource <[email protected]> | |
* @license : MIT https://opensource.org/licenses/MIT | |
* | |
* usage: | |
* | |
* ```php | |
* require_once 'Debug.php'; | |
* Debug::init(); | |
* Debug::log($myVar); | |
* Debug::log($myArray); | |
* ``` | |
*/ | |
class Debug { | |
protected static $name = 'debug'; | |
public static function init() { | |
if(!file_exists(self::filename())) { | |
self::log('Debug File Init'); | |
} | |
} | |
public static function log($param) { | |
if (is_array($param)) { | |
$param = json_encode($param); | |
} | |
wire('log')->save(self::$name, $param); | |
} | |
public static function filename() { | |
return wire('log')->getFilename(self::$name); | |
} | |
public static function name() { | |
return self::$name; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment