Implementation of script change_loglevel.py in PHP