<commit_before>/*
    This and Log should really be merged, and some things from Log should move to SystemUtil or something.
*/
package flaxen.util;

#if !flash
import sys.io.File;
import sys.io.FileOutput;
#end

import flaxen.util.ArrayUtil;

class LogUtil
{
    #if !flash
        public static function dumpLog(engine:ash.core.Engine, filename:String, depth:Int = 1, preventRecursion = true): Void
        {
            var fo:FileOutput = File.write(filename);
            fo.writeString("ASH ENTITIES:\n");
            for(entity in engine.entities)
            {
                var str:String = dumpEntity(entity, depth, preventRecursion);
                fo.writeString(str + "\n");
            }
        }
    #end

    public static function assert(cond: Bool, ?pos:haxe.PosInfos)
    {
        if(!cond)
           haxe.Log.trace("Assert in " + pos.className + "::" + pos.methodName, pos);
    }

    public static function dumpEntity(entity:ash.core.Entity, depth:Int = 1, preventRecursion = true): String
    {
    	var result = entity.name + ":{\n";
    	var sep = "";
    	for(c in entity.getAll())
    	{
    		result += sep + dump(c, depth, preventRecursion);
    		sep = ",\n";
    	}
    	return result + "}";
    }

    public static function dumpHaxePunk(scene:com.haxepunk.Scene): String
    {
    	var ret = "HAXEPUNK ENTITIES:\n";
    	var arr = new Array<com.haxepunk.Entity>();
    	scene.getAll(arr);
    	for(e in arr)
    	{
    		if(e.name != null && e.name != "")<commit_msg>Added close to log dump<commit_after>/*
    This and Log should really be merged, and some things from Log should move to SystemUtil or something.
*/
package flaxen.util;

#if !flash
import sys.io.File;
import sys.io.FileOutput;
#end

import flaxen.util.ArrayUtil;

class LogUtil
{
    #if !flash
        public static function dumpLog(engine:ash.core.Engine, filename:String, depth:Int = 1, preventRecursion = true): Void
        {
            var fo:FileOutput = File.write(filename);
            fo.writeString("ASH ENTITIES:\n");
            for(entity in engine.entities)
            {
                var str:String = dumpEntity(entity, depth, preventRecursion);
                fo.writeString(str + "\n");
            }
            fo.close();
        }
    #end

    public static function assert(cond: Bool, ?pos:haxe.PosInfos)
    {
        if(!cond)
           haxe.Log.trace("Assert in " + pos.className + "::" + pos.methodName, pos);
    }

    public static function dumpEntity(entity:ash.core.Entity, depth:Int = 1, preventRecursion = true): String
    {
    	var result = entity.name + ":{\n";
    	var sep = "";
    	for(c in entity.getAll())
    	{
    		result += sep + dump(c, depth, preventRecursion);
    		sep = ",\n";
    	}
    	return result + "}";
    }

    public static function dumpHaxePunk(scene:com.haxepunk.Scene): String
    {
    	var ret = "HAXEPUNK ENTITIES:\n";
    	var arr = new Array<com.haxepunk.Entity>();
    	scene.getAll(arr);
    	for(e in arr)
    	{
    		if(e.name != null && e.name != "")
{'fraction_non_alphanumeric': 0.13066316480630336, 'fraction_numerical': 0.0013131976362442547, 'mean_word_length': 2.2869471413160736, 'pattern_counts': {'":': 4, '<': 5, '<?xml version=': 0, '>': 5, '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': '2987594', 'n_tokens_mistral': 1017, 'n_tokens_neox': 1002, 'n_words': 243}