* in the formatting of the output.
*
* @param string $variable_name
+ * Variable name.
* @param mixed $variable
+ * Variable value.
* @param bool $print
- * Should we use print_r ? (else we use var_dump).
+ * Use print_r (if true) or var_dump (if false).
* @param bool $log
- * Should we log or return the output.
- * @param string $comp
- * Variable name.
+ * Log or return the output?
+ * @param string $prefix
+ * Prefix for output logfile.
*
* @return string
- * the generated output
- *
- *
+ * The generated output
*
* @see CRM_Core_Error::debug()
* @see CRM_Core_Error::debug_log_message()
*/
- public static function debug_var(
- $variable_name,
- $variable,
- $print = TRUE,
- $log = TRUE,
- $comp = ''
- ) {
+ public static function debug_var($variable_name, $variable, $print = TRUE, $log = TRUE, $prefix = '') {
// check if variable is set
if (!isset($variable)) {
$out = "\$$variable_name is not set";
reset($variable);
}
}
- return self::debug_log_message($out, FALSE, $comp);
+ return self::debug_log_message($out, FALSE, $prefix);
}
/**
* @param bool $out
* Should we log or return the output.
*
- * @param string $comp
- * Message to be output.
+ * @param string $prefix
+ * Message prefix.
* @param string $priority
*
* @return string
* Format of the backtrace
*/
- public static function debug_log_message($message, $out = FALSE, $comp = '', $priority = NULL) {
+ public static function debug_log_message($message, $out = FALSE, $prefix = '', $priority = NULL) {
$config = CRM_Core_Config::singleton();
- $file_log = self::createDebugLogger($comp);
+ $file_log = self::createDebugLogger($prefix);
$file_log->log("$message\n", $priority);
$str = '<p/><code>' . htmlspecialchars($message) . '</code>';
/**
* Generate the name of the logfile to use and store it as a static.
*
- * This function includes poor man's log file management and a check as to whether the file exists.
+ * This function includes simplistic log rotation and a check as to whether
+ * the file exists.
*
* @param string $prefix
*/
$hash = self::generateLogFileHash($config);
$fileName = $config->configAndLogDir . 'CiviCRM.' . $prefixString . $hash . '.log';
- // Roll log file monthly or if greater than 256M
- // note that PHP file functions have a limit of 2G and hence
- // the alternative was introduce
+ // Roll log file monthly or if greater than 256M.
+ // Size-based rotation introduced in response to filesize limits on
+ // certain OS/PHP combos.
if (file_exists($fileName)) {
$fileTime = date("Ym", filemtime($fileName));
$fileSize = filesize($fileName);