Support thread-local/scoped color overrides
jam1garner opened this issue · comments
jam1garner commented
Moving this from #33 to its own issue.
One considered API design:
// color=always
scoped_override(true, || {
// do stuff here?
});
// color=never
scoped_override(false, || {
// do stuff here?
});
This would need to be behind a feature flag as it requires std for thread-local variables, but outside of that this isn't too bad. For the most part it should be able to reuse a lot of the code from #34, but replace the static with a thread local.
Outstanding Design Questions
- Should scoped overrides or global overrides take precedence?
Rain commented
Should scoped overrides or global overrides take precedence?
I would personally expect that thread-local overrides, being more local than process-wide overrides, take precedence. (Similarly, task-local overrides should take precedence over thread-local ones I think)