This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cayenne.git
commit 3771c27dcbb8dd91177d7bc707402783330d96d2 Author: Andrus Adamchik <[email protected]> AuthorDate: Sun May 17 12:17:47 2026 -0400 CAY-2940 Upgrade to SLF4J version 2.0.17 --- .../modeler/log/ModelerLogServiceProvider.java | 66 ++++++++++++++++++++++ .../java/org/slf4j/impl/StaticLoggerBinder.java | 49 ---------------- .../services/org.slf4j.spi.SLF4JServiceProvider | 1 + 3 files changed, 67 insertions(+), 49 deletions(-) diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/log/ModelerLogServiceProvider.java b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/log/ModelerLogServiceProvider.java new file mode 100644 index 000000000..281c5214d --- /dev/null +++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/log/ModelerLogServiceProvider.java @@ -0,0 +1,66 @@ +/***************************************************************** + * 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 + * + * https://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.apache.cayenne.modeler.log; + +import org.slf4j.ILoggerFactory; +import org.slf4j.IMarkerFactory; +import org.slf4j.helpers.BasicMDCAdapter; +import org.slf4j.helpers.BasicMarkerFactory; +import org.slf4j.spi.MDCAdapter; +import org.slf4j.spi.SLF4JServiceProvider; + +/** + * SLF4J 2.x service provider that routes logging through {@link ModelerLogFactory}. + * Discovered via {@code META-INF/services/org.slf4j.spi.SLF4JServiceProvider}. + */ +public class ModelerLogServiceProvider implements SLF4JServiceProvider { + + public static final String REQUESTED_API_VERSION = "2.0.99"; + + private ILoggerFactory loggerFactory; + private IMarkerFactory markerFactory; + private MDCAdapter mdcAdapter; + + @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() { + loggerFactory = new ModelerLogFactory(); + markerFactory = new BasicMarkerFactory(); + mdcAdapter = new BasicMDCAdapter(); + } +} diff --git a/modeler/cayenne-modeler/src/main/java/org/slf4j/impl/StaticLoggerBinder.java b/modeler/cayenne-modeler/src/main/java/org/slf4j/impl/StaticLoggerBinder.java deleted file mode 100644 index ad3e72a2a..000000000 --- a/modeler/cayenne-modeler/src/main/java/org/slf4j/impl/StaticLoggerBinder.java +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************** - * 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 - * - * https://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.impl; - -import org.apache.cayenne.modeler.log.ModelerLogFactory; -import org.slf4j.ILoggerFactory; -import org.slf4j.spi.LoggerFactoryBinder; - -/** - * StaticLoggerBinder bind and replace standard SLF4J LoggerFactory to ModelerLogFactory. - * This is used because in Cayenne Modeler we use custom logger implementation (ModelerLogger) - * for logging in System.err and modeler logger. - */ -public class StaticLoggerBinder implements LoggerFactoryBinder { - - private final static StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); - private final static String LOGGER_FACTORY_CLASS_STR = ModelerLogFactory.class.getName(); - - private final ILoggerFactory loggerFactory = new ModelerLogFactory(); - - public static StaticLoggerBinder getSingleton() { - return SINGLETON; - } - - public ILoggerFactory getLoggerFactory() { - return this.loggerFactory; - } - - public String getLoggerFactoryClassStr() { - return LOGGER_FACTORY_CLASS_STR; - } -} diff --git a/modeler/cayenne-modeler/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider b/modeler/cayenne-modeler/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider new file mode 100644 index 000000000..37c137857 --- /dev/null +++ b/modeler/cayenne-modeler/src/main/resources/META-INF/services/org.slf4j.spi.SLF4JServiceProvider @@ -0,0 +1 @@ +org.apache.cayenne.modeler.log.ModelerLogServiceProvider
