<commit_before><?php

function dbug() {
	if ($GLOBALS['cfg']['environment'] != 'dev') {
		return;
	}

	if (! $GLOBALS['dbug_fh']) {
		$root = dirname(dirname(__DIR__));
		$GLOBALS['dbug_fh'] = fopen($GLOBALS['cfg']['dbug_log'], 'a');
	}

	$args = func_get_args();
	foreach ($args as $arg) {
		if (! is_scalar($arg)) {
			$arg = print_r($arg, true);
		}
		$arg = trim($arg);
		$prefix = date('[Y-m-d H:i:s] ');
		fwrite($GLOBALS['dbug_fh'], "$prefix $arg\n");
	}
}<commit_msg>:bug: be more careful with opening the dbug log<commit_after><?php

function dbug() {
	if ($GLOBALS['cfg']['environment'] != 'dev') {
		return;
	}

	if (! $GLOBALS['dbug_fh']) {
		$root = dirname(dirname(__DIR__));
		$GLOBALS['dbug_fh'] = @fopen($GLOBALS['cfg']['dbug_log'], 'a');
	}

	if (! is_resource($GLOBALS['dbug_fh'])) {
		error_log("Could not write dbug() message to {$GLOBALS['cfg']['dbug_log']}");
		return;
	}

	$args = func_get_args();
	foreach ($args as $arg) {
		if (! is_scalar($arg)) {
			$arg = print_r($arg, true);
		}
		$arg = trim($arg);
		$prefix = date('[Y-m-d H:i:s] ');
		fwrite($GLOBALS['dbug_fh'], "$prefix $arg\n");
	}
}
{'fraction_non_alphanumeric': 0.25133689839572193, 'fraction_numerical': 0.0, 'mean_word_length': 4.700507614213198, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7025310', 'n_tokens_mistral': 497, 'n_tokens_neox': 463, 'n_words': 84}