Skip to content

Instantly share code, notes, and snippets.

@Mikulas
Created May 4, 2011 18:55
Show Gist options
  • Save Mikulas/955777 to your computer and use it in GitHub Desktop.
Save Mikulas/955777 to your computer and use it in GitHub Desktop.
Logger
<?php
require "./Breto/libs/nette/loader.php";
class CustomDump
{
static public $file;
static function setFile($file) {
self::$file = $file;
}
static function log($a = NULL)
{
$file = fopen(self::$file, "a+");
foreach (func_get_args() as $arg) {
fwrite($file, Nette\Diagnostics\Debugger::dump($arg, TRUE));
}
fclose($file);
}
}
class Foo
{
public $prop = 'value';
function test($arg)
{
// hardcore ajax action
CustomDump::log($this, get_defined_vars());
}
}
CustomDump::setFile('log.txt');
$foo = new Foo;
$arg = 'a456sd';
$foo->test($arg);
@Mikulas
Copy link
Author

Mikulas commented May 4, 2011

mikulas-dites-imac:Web Mikulas$ cat log.txt
Foo(1) {
   "prop" => "value" (5)
}

array(2) {
   "arg" => "a456sd" (6)
   "this" => Foo(1) {
      "prop" => "value" (5)
   }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment