summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Gass2022-06-22 10:36:44 +0200
committerNathan Gass2022-06-22 10:36:44 +0200
commitc8327bdc857ea26ec576d5c5d1070dcfd815c033 (patch)
tree9a7ca9296656982e4171d113341639b7322a3d0c
parent72010f5b4d1aee57e1ace054b91ab579d630366d (diff)
downloaditools-c8327bdc857ea26ec576d5c5d1070dcfd815c033.tar.gz
itools-c8327bdc857ea26ec576d5c5d1070dcfd815c033.tar.bz2
itools-c8327bdc857ea26ec576d5c5d1070dcfd815c033.zip
ED output to stderror if IT_ED_STDERR is set
-rw-r--r--auto_prepend.php7
-rw-r--r--it_debug.class8
2 files changed, 12 insertions, 3 deletions
diff --git a/auto_prepend.php b/auto_prepend.php
index 528769f..19108fb 100644
--- a/auto_prepend.php
+++ b/auto_prepend.php
@@ -16,7 +16,7 @@ function D(...$args)
function ED(...$args)
{
it_debug::setup();
- echo it_debug::dump($args);
+ it_debug::echo($args);
return $args[0];
}
@@ -33,7 +33,7 @@ function EDC($var, ...$args)
if ($args)
{
it_debug::setup();
- echo it_debug::dump($args);
+ it_debug::echo($args);
}
if (!$result || $result === true) # Compatibility with old map relying on 0|1
@@ -51,7 +51,8 @@ function EDX(...$args)
if ($_SERVER['REMOTE_ADDR'] && !headers_sent())
header("Content-Type: text/html"); # Not going to be e.g. a valid gif anyway
- exit(it_debug::dump($args));
+ it_debug::echo($args);
+ exit();
}
diff --git a/it_debug.class b/it_debug.class
index a504be8..c4bc8db 100644
--- a/it_debug.class
+++ b/it_debug.class
@@ -51,6 +51,14 @@ function debug($text, $level = 0)
}
}
+static function echo($args)
+{
+ if (getenv('IT_ED_STDERR'))
+ fputs(STDERR, self::dump($args));
+ else
+ echo self::dump($args);
+}
+
/**
* Get source line of grandparent calling this function
* @param $stacksoffs go up an extra $stacksoffs levels