You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If not done several extensions don't work with mvnsh, a better solution would be to support both depending the build but it is harder than staying aligned on mvn defaults.
Potential implementation:
public class Slf4jLoggingSystem implements LoggingSystem {
private static final List<Level> ALL_LEVELS = ImmutableList.of(
Level.ALL,
Level.TRACE,
Level.DEBUG,
Level.INFO,
Level.WARN,
Level.ERROR,
Level.OFF
);
private static final List<LevelComponent> LEVELS = ALL_LEVELS.stream()
.map(Level::name)
.map(LevelComponentImpl::new)
.collect(toList());
private final ConcurrentMap<String, LoggerComponent> loggers = new ConcurrentHashMap<>();
@Override
public LevelComponent getLevel(final String name) {
checkNotNull(name);
return LEVELS.stream().filter(it -> it.getName().equalsIgnoreCase(name)).findFirst()
.orElseThrow(() -> new IllegalArgumentException("No level " + name));
}
@Override
public Collection<? extends LevelComponent> getLevels() {
return LEVELS;
}
@Override
public LoggerComponent getLogger(final String s) {
return loggers.computeIfAbsent(s, k -> {
final Logger logger = LoggerFactory.getLogger(k);
return new LoggerComponentImpl(logger, findLevel(logger));
});
}
private LevelComponent findLevel(final Logger logger) {
if (logger.isTraceEnabled()) {
return getLevel("TRACE");
}
if (logger.isDebugEnabled()) {
return getLevel("DEBUG");
}
if (logger.isInfoEnabled()) {
return getLevel("INFO");
}
if (logger.isWarnEnabled()) {
return getLevel("WARN");
}
if (logger.isErrorEnabled()) {
return getLevel("ERROR");
}
return getLevel("OFF");
}
@Override
public Collection<String> getLoggerNames() {
return loggers.keySet();
}
@Override
public Collection<? extends LoggingComponent> getComponents() {
return emptyList();
}
private static class LevelComponentImpl implements LevelComponent {
private final String level;
private LevelComponentImpl(final String name) {
this.level = name.toUpperCase(ROOT);
}
@Override
public String getName() {
return level;
}
}
private static class LoggerComponentImpl implements LoggerComponent {
private final Logger logger;
private final LevelComponent level;
private LoggerComponentImpl(final Logger logger, final LevelComponent level) {
this.logger = logger;
this.level = level;
}
@Override
public String getName() {
return logger.getName();
}
@Override
public LevelComponent getLevel() {
return level;
}
@Override
public void setLevel(final LevelComponent levelComponent) {
// no-op
}
@Override
public void setLevel(final String s) {
// no-op
}
@Override
public boolean isRoot() {
return "".equals(getName()) || "ROOT".equals(getName());
}
}
}
The text was updated successfully, but these errors were encountered:
Will have a look. Originally mvn didn't have any sane logging and only in recent history has it finally adopted slf4j so there are some conflicts with base-gshell and mvn here.
If not done several extensions don't work with mvnsh, a better solution would be to support both depending the build but it is harder than staying aligned on mvn defaults.
Potential implementation:
The text was updated successfully, but these errors were encountered: