How to pass cargo features in multilevel dependencies?

Here's the situation, my crate custom-log use slog as a dependency.

name = "custom_log"
slog = { version = "2.5.2" }

And I want to change the logging level by using features with custom-log which means that if any package set the features with custom_log, I want to custom_log pass the feature to slog.

I tried to rename the name of dependency with slog:

default = ["slog"]
debug = ["slog_debug"]

slog = { version = "2.5.2", optional = true }
slog_debug = { package = "slog", version = "2.5.2", features = ["max_level_debug", "release_max_level_debug"], optional = true }

But I got the error below:

error: the crate `custom_log v0.1.1 ` depends on crate `slog v2.5.2` multiple times with different names

So I know that Cargo forbids duplicate references to a package.

Is there any recommended way to do this?

Your feature can activate "dependency/feature".

debug = ["slog/debug"]

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.