Copilot commented on code in PR #11880: URL: https://github.com/apache/maven/pull/11880#discussion_r3049447099
########## maven-slf4j-provider/src/main/java/org/slf4j/simple/MavenSimpleServiceProvider.java: ########## @@ -0,0 +1,71 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.slf4j.simple; + +import org.slf4j.ILoggerFactory; +import org.slf4j.IMarkerFactory; +import org.slf4j.helpers.BasicMarkerFactory; +import org.slf4j.helpers.NOPMDCAdapter; +import org.slf4j.spi.MDCAdapter; +import org.slf4j.spi.SLF4JServiceProvider; + +/** + * SLF4J service provider for Maven, using {@link MavenSimpleLoggerFactory} + * to provide colorized log output. + * + * @since 3.10.0 + */ +public class MavenSimpleServiceProvider implements SLF4JServiceProvider { + + /** + * Declare the version of the SLF4J API this implementation is compiled against. + */ + // to avoid constant folding by the compiler, this field must *not* be final + @SuppressWarnings({"checkstyle:staticvariablename", "checkstyle:visibilitymodifier"}) + public static String REQUESTED_API_VERSION = "2.0"; // !final + + private ILoggerFactory loggerFactory; + private final IMarkerFactory markerFactory = new BasicMarkerFactory(); + private final MDCAdapter mdcAdapter = new NOPMDCAdapter(); + + @Override + public ILoggerFactory getLoggerFactory() { + return loggerFactory; + } + + @Override + public IMarkerFactory getMarkerFactory() { + return markerFactory; + } + + @Override + public MDCAdapter getMDCAdapter() { + return mdcAdapter; + } + + @Override + public String getRequestedApiVersion() { + return REQUESTED_API_VERSION; + } + + @Override + public void initialize() { Review Comment: `MavenSimpleServiceProvider.initialize()` only instantiates `MavenSimpleLoggerFactory`, but does not perform the `SimpleLogger` initialization that slf4j-simple typically requires. With SLF4J 2.x providers, the provider’s `initialize()` is the right place to call `SimpleLogger.init()` (and any required factory reset) so configuration/system properties are applied before loggers are used. ```suggestion public void initialize() { SimpleLogger.init(); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
