function testLogFileBasic() { $blank_log = log_file_location(); $this->assertEquals('/', $blank_log[0]); $file = 'main.log'; $this->assertEquals('main.log', log_file_location($file)); define('LOG', '/tmp/'); $this->assertEquals('/tmp/main.log', log_file_location($file)); $file = '/dev/' . $file; $this->assertEquals('/dev/main.log', log_file_location($file)); }
function log_file($log, $var = null, $file = null, $overwrite = false) { $file = log_file_location($file); $log = '----Logged on ' . date('r') . ' ----' . PHP_EOL . PHP_EOL . '$' . $var . ': ' . ((is_array($log) or is_object($log)) ? print_r($log, true) : $log) . PHP_EOL . PHP_EOL; file_save_($file, $log, $overwrite); return true; }