Skip to content

src: feature-flag default logger, start/with_level#661

Merged
yoshuawuyts merged 1 commit intohttp-rs:masterfrom
Fishrock123:logger-middleware-feature-flag
Jul 25, 2020
Merged

src: feature-flag default logger, start/with_level#661
yoshuawuyts merged 1 commit intohttp-rs:masterfrom
Fishrock123:logger-middleware-feature-flag

Conversation

@Fishrock123
Copy link
Member

@Fishrock123 Fishrock123 commented Jul 25, 2020

Refs: #548

The easier to fix that and related issues.

This doesn't tackle CookiesMiddleware because it's practically necessary, I think?

@vladan
Copy link
Contributor

vladan commented Jul 25, 2020

This won't resolve the issue of duplicate log entries when using nested routes, i.e. when the logging middleware flag is enabled, duplicate log entries will still appear, right?
IMHO this creates more work for the user than #468 in that the feature flag needs to be unset and the user should set up a logging middleware from scratch ... it's likely I'm wrong, just feels a bit too much work, and some overhead of having a feature flag for just the logger.

Copy link
Member

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably scope the entire logger submodule behind a feature flag; but this looks reasonable enough to merge. Thanks!

@yoshuawuyts yoshuawuyts merged commit 724afc9 into http-rs:master Jul 25, 2020
@Fishrock123 Fishrock123 deleted the logger-middleware-feature-flag branch July 26, 2020 06:15
@Fishrock123
Copy link
Member Author

@vladan i bliebe the answer will likely end up being a TypeMap for Middleware. I’ll try to look at your PR and into this more this coming week.

@jbr
Copy link
Member

jbr commented Jul 26, 2020

@Fishrock123 how would a typemap work? Middleware are ordered, and also should be able to accommodate more than one instance of a given type

@Fishrock123
Copy link
Member Author

Sorry perhaps not a type map but maybe some kind of typeId registry, where a middleware can optionally choose to say that it should only be one, or specify a needed dependency.

@jbr
Copy link
Member

jbr commented Jul 26, 2020

That seems complex. What problem does it solve? Also how could a middleware know if it's the only one of it's type? That imposes a constraint on middleware that limits the utility. Is this so we have a way to downcast from dyn Middleware? We could just have a DynMiddleware struct that captures the typeid and provides a downcast, and then have a Vec<DynMiddleware>

@jbr
Copy link
Member

jbr commented Jul 26, 2020

@Fishrock123 for the "only run once" thing, see #662 for a proposal that doesn't require any changes to the middleware implementation and allows an individual middleware to configure it's "run-once" behavior

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

Successfully merging this pull request may close these issues.

4 participants