21/09
2015
Wallogit.com
2017 © Pedro Peláez
Kernighan style eprint utility functions for php
Kernighan style eprint utility functions for php, (*1)
eprint -- formatted stderr printing utility functions, (*2)
function eprint($msg), (*3)
function nprint($msg), (*4)
function wprint($msg), (*5)
All functions will print a message to STDERR prepended with date, filename, pid and the level depending on the function used. The eprint() function will additionaly halt the execution with exit(2). If $msg is passed as a multiline string, it will be indented to emphasize it's multiline nature., (*6)
the following code, (*7)
nprint('this is a notice'); nprint('this is a dump of the $_ENV '. print_r($_ENV, true)); wprint('this should be checked sometime'); eprint('and this will stop the execution');
will output, (*8)
2015-09-21 19:35:55 printme [81662] notice: this is a notice 2015-09-21 19:35:55 printme [81662] notice: this is a dump of the $_ENV Array ( [PAGER] => more [EDITOR] => vi [...] [SHELL] => /bin/sh [BLOCKSIZE] => K ) 2015-09-21 19:35:55 printme [81662] warning: this should be checked sometime 2015-09-21 19:35:55 printme [81662] error: and this will stop the execution