HaxeFlixel / flixel-docs

Documentation for HaxeFlixel
72 stars 135 forks source link

Suggestion: FLX_DEBUG_STRICT #284

Closed chosencharacters closed 3 months ago

chosencharacters commented 4 months ago

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 commented 4 months ago

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 commented 3 months ago

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

chosencharacters commented 3 months ago

Yes and with great shame that it opened in the first place :(

On Tue, May 14, 2024 at 1:50 PM George Kurelic @.***> wrote:

@chosencharacters https://github.com/chosencharacters can this be closed, given the proposed workaround?

— Reply to this email directly, view it on GitHub https://github.com/HaxeFlixel/flixel-docs/issues/284#issuecomment-2110797574, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKA4BFJYGNRMTKU7J7NMLZCJFFNAVCNFSM6AAAAABGVNBBS2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJQG44TONJXGQ . You are receiving this because you were mentioned.Message ID: @.***>

Geokureli commented 3 months ago

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

chosencharacters commented 3 months ago

Too late shame has already been taken

On Tue, May 14, 2024 at 1:53 PM George Kurelic @.***> wrote:

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

— Reply to this email directly, view it on GitHub https://github.com/HaxeFlixel/flixel-docs/issues/284#issuecomment-2110803411, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFNKA4BNPV7JAG4BJ6VRM2TZCJFTLAVCNFSM6AAAAABGVNBBS2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJQHAYDGNBRGE . You are receiving this because you were mentioned.Message ID: @.***>