Skip to content

Commit

Permalink
Merge pull request #7 from andimiller/slf4j2
Browse files Browse the repository at this point in the history
Add Slf4j2 Module
  • Loading branch information
alejandrohdezma authored Jul 16, 2024
2 parents 243496d + fb7f5fd commit 824aa23
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
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

0 comments on commit 824aa23

Please sign in to comment.