Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: FLX_DEBUG_STRICT #284

Closed
chosencharacters opened this issue Apr 23, 2024 · 5 comments
Closed

Suggestion: FLX_DEBUG_STRICT #284

chosencharacters opened this issue Apr 23, 2024 · 5 comments

Comments

@chosencharacters
Copy link

chosencharacters commented Apr 23, 2024

I keep adding this flag to my own version of flixel but FLX_DEBUG_STRICT is a flag that causes Logs (specifically animation logs) to throw an error instead of logging. This is useful for in-dev projects that have tons of animations and would rather have a stack trace the moment an issue happens.

Example lines
https://github.com/HaxeFlixel/flixel/blob/7e7eb5cfe31e2ccbdc49561ca90b7d9108d3d2c3/flixel/animation/FlxAnimationController.hx#L203
https://github.com/HaxeFlixel/flixel/blob/7e7eb5cfe31e2ccbdc49561ca90b7d9108d3d2c3/flixel/animation/FlxAnimationController.hx#L234
https://github.com/HaxeFlixel/flixel/blob/7e7eb5cfe31e2ccbdc49561ca90b7d9108d3d2c3/flixel/animation/FlxAnimationController.hx#L237
https://github.com/HaxeFlixel/flixel/blob/7e7eb5cfe31e2ccbdc49561ca90b7d9108d3d2c3/flixel/animation/FlxAnimationController.hx#L269

(and any other line where a log is)

example change for L203 would be

#if FLX_DEBUG_STRICT
throw 'Could not append frames above ${numFrames - 1} to animation: "$name"'
#else
FlxG.log.warn('Could not append frames above ${numFrames - 1} to animation: "$name"');
#end

(You could alternatively add it to the actual Flixel logger)

https://github.com/HaxeFlixel/flixel/blob/7e7eb5cfe31e2ccbdc49561ca90b7d9108d3d2c3/flixel/system/frontEnds/LogFrontEnd.hx#L27

#if FLX_DEBUG_STRICT
throw data;
#else
advanced(data, LogStyle.WARNING, true);
#end
@Geokureli
Copy link
Member

You can already change any log style to throw an exception via:

LogStyle.ERROR.throwException = true;

then whenever you call FlxG.log.error or FlxG.log.advance(data, LogStyle.ERROR) it'll throw an exception

@Geokureli
Copy link
Member

@chosencharacters can this be closed, given the proposed workaround?

@chosencharacters
Copy link
Author

chosencharacters commented May 14, 2024 via email

@Geokureli
Copy link
Member

Geokureli commented May 14, 2024

No shame, Flixel's logging tools are not well-known, and it's hard to teach them via demos and snippets

@chosencharacters
Copy link
Author

chosencharacters commented May 14, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants