tschneidereit / SwiftSuspenders

NOTE: Find the offical repo at http://github.com/robotlegs/swiftsuspenders
https://github.com/robotlegs/swiftsuspenders
MIT License
280 stars 89 forks source link

loggable warning #64

Closed darscan closed 12 years ago

darscan commented 12 years ago

I was wondering if it would be possible to hook into the warnings, so that they could be logged. Perhaps dispatch an event.

tschneidereit commented 12 years ago

I was thinking about using whatever RL uses for logging in Swiftsuspenders, too. Do you think that the small amount of traces (and the seeming lack of need for adding more) doesn't justify that? If so, and you may well be right, I guess events are the way to go.

OTOH, getting a reasonable dispatcher to one of the places where the warning are traced might not be too easy. That place is the DescribeTypeReflector warning about ctors doing stuff they shouldn't while creating a dummy instance. But then again, that might not matter too much because not having Flash Player 10.1 should be pretty rare nowadays.

But then again (it's getting ridiculous, I know), maybe logs are especially important in extraordinary circumstances?

Oh, and the only other place where a warning is now traced - overriding an existing mapping - should maybe just turn into an exception. It certainly has burned Robotlegs enough to warrant that ...

darscan commented 12 years ago

I don't like what's currently in place in Robotlegs. I "tried" to go for a simple callback approach, but went overboard making it neither small nor simple nor flexible. Anyhoo, am keen to try the "simple callback" approach again sometime soon.

Oh, and the only other place where a warning is now traced - overriding an existing mapping - should maybe just turn into an exception.

Perhaps.. a bit harsh. Maybe strict mode for each injector by default, with option to log (or trace if the logger is not set).

tschneidereit commented 12 years ago

So I've added an event for the mapping override-case, but not for the other trace, because that's nigh impossible to dispatch on something useful to users.

Also, I've finally settled on not making mapping overrides throw. Thanks for the input.

darscan commented 12 years ago

Cool stuff. The other trace doesn't matter too much anyway (being pre-10.1).