unicode-org / icu4x

Solving i18n for client-side and resource-constrained environments.
https://icu4x.unicode.org
Other
1.37k stars 176 forks source link

Use more log::warns in the code #2648

Open Manishearth opened 2 years ago

Manishearth commented 2 years ago

We have a bunch of debug asserts that could probably be log::warn for better user experience.

Perhaps also have a strict_assert feature that switches between warning and panicking for testing purposes,.

robertbastian commented 1 year ago

+1 to logging, -1 to panicking based on a feature. We should condition on debug_assertions and say we're panic-free in release mode.

sffc commented 1 year ago

Should the warnings be behind a feature? Should we route all the warnings through an intermediate crate like icu_provider?

Discuss with:

Manishearth commented 1 year ago

+1 behind a feature, am ambivalent about routing through icu_provider but I think that makes sense as a global toggle instead of adding features everywhere

sffc commented 1 year ago

@Manishearth proposal: the feature exists in 2 places: icu and icu_provider (or could be icu_core). When you enable it, everyone in your dependency tree gets it.

Conclusion:

LGTM: @sffc @Manishearth @robertbastian @skius @zbraniecki

robertbastian commented 1 year ago

icu_datagen currently doesn't have a logging feature and logging is a pretty fundamental part of its behaviour. Logging can actually be turned off by not registering a logger, so I'm not sure we need a separate feature...

sffc commented 1 year ago

It would be nice if all ICU4X docs tests and unit tests would have logging enabled. Currently we have logs in the code to catch possibly-errorful conditions, but those logs are suppressed, making it difficult to debug (@atcupps).

Context: The use case is that if we don't recognize a calendar BCP-47 identifier, we fall back to the locale's default calendar, which is correct, expected logic, and we have a warning printed when this fallback occurs, but that warning is not being printed in unit tests.