<?php
////logging

// Define the _log() function only if it doesn't already exist
if (!function_exists('_log')) {
  function _log($str) {
    $relcrudpath='';
    $logging = $_SESSION['logging'];
    // log to the output
    if (substr($str, 1, 5) == '-----') {
        $log_str = "{$str}\r\n"; // no date if separator
    } else {
        $log_str = date('m.d.Y').": {$str}\r\n";
    }
    // log to file if on in UI
    if ($logging) {
          $relcrudpath = $_SESSION['relcrudpath'];
	    $file_system_path = $relcrudpath . '/StacksCal.log';
        file_put_contents($file_system_path, $log_str, FILE_APPEND);
    }
  }
}

?>