Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Slf4j2 Module #7

Merged
merged 2 commits into from
Jul 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ In benchmarks, the bridge performs as well as [Log4Cats] with a [Logback] backen
"com.permutive" %% "odin-slf4j-bridge" "<VERSION>"
```

## [`odin-slf4j2-bridge`]

A bridge between [Odin] and [Slf4j] versions 2 and above, allowing the dynamic [Odin] logger to be used by default for [Slf4j] log messages.

[`odin-testing`]: odin-testing
[`log4cats-odin`]: log4cats-odin
[`odin-dynamic`]: odin-dynamic
Expand Down
4 changes: 4 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ lazy val `odin-slf4j-bridge` = module
.settings(libraryDependencies += "com.github.valskalla" %% "odin-core" % "0.13.0")
.settings(libraryDependencies += "org.slf4j" % "slf4j-api" % "1.7.36") // scala-steward:off

lazy val `odin-slf4j2-bridge` = module
.dependsOn(`odin-slf4j-bridge`)
.settings(libraryDependencies += "org.slf4j" % "slf4j-api" % "2.0.13")

lazy val `odin-slf4j-bridge-benchmarks` = module
.enablePlugins(JmhPlugin)
.dependsOn(`odin-slf4j-bridge`)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2022-2024 Permutive Ltd. <https://permutive.com>
*
* Licensed 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.impl;

import com.permutive.logging.slf4j.odin.LoggerFactory;
import org.slf4j.ILoggerFactory;
import org.slf4j.IMarkerFactory;
import org.slf4j.helpers.BasicMDCAdapter;
import org.slf4j.spi.MDCAdapter;
import org.slf4j.spi.SLF4JServiceProvider;


public class OdinBridge implements SLF4JServiceProvider {

@Override
public ILoggerFactory getLoggerFactory() {
return new LoggerFactory();
}

@Override
public IMarkerFactory getMarkerFactory() {
return null;
}

@Override
public MDCAdapter getMDCAdapter() {
return new BasicMDCAdapter();
}

@Override
public String getRequestedApiVersion() {
return "2.0";
}

@Override
public void initialize() {

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.slf4j.impl.OdinBridge