Provide standard function across all languages for debugging

I’ve noticed there is the ability to debug in all the languages. However, Id like to take it a step further with a standard interface. Instead of doing the following for each language:

PHP:

// To debug (equivalent to var_dump): error_log(var_export($var, true));

function debug($x) {
   error_log(var_export($x, true));
}

Javascript:

// To debug: printErr('Debug messages...');

function debug(x) {
       printErr(x);
}

Python:

# To debug: print("Debug messages...", file=sys.stderr)

 def debug (x):
    print(x, file=sys.stderr)
    return

How about adding a standard function, in this case I’m just using “debug” to every language? This way you only need to add the following comment:

# To debug use the function: debug();
4 Likes