-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Logging > The current TurboFilterList implementation of logback-class…
…ic which calls the TurboFilters is a CopyOnWriteArrayList. This means every time any logger method is called the array of TurboFilters is copied. As we are using the logger extensively this small copy is visible in the flamegraph. A call to isXLevelEnabled check does not avoid this path.
- Loading branch information
Showing
13 changed files
with
437 additions
and
379 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/main/java/com/hivemq/logging/LogLevelModifierTurboFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2019-present HiveMQ GmbH | ||
* | ||
* 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 com.hivemq.logging; | ||
|
||
import ch.qos.logback.classic.Level; | ||
import ch.qos.logback.classic.Logger; | ||
import ch.qos.logback.classic.turbo.TurboFilter; | ||
import ch.qos.logback.core.spi.FilterReply; | ||
import com.hivemq.extension.sdk.api.annotations.NotNull; | ||
import com.hivemq.extension.sdk.api.annotations.Nullable; | ||
import com.hivemq.logging.modifier.LogLevelModifier; | ||
import org.slf4j.Marker; | ||
|
||
import java.util.List; | ||
import java.util.concurrent.CopyOnWriteArrayList; | ||
|
||
public class LogLevelModifierTurboFilter extends TurboFilter { | ||
|
||
private final @NotNull List<LogLevelModifier> logLevelModifiers = new CopyOnWriteArrayList<>(); | ||
|
||
@Override | ||
public @NotNull FilterReply decide( | ||
final @Nullable Marker marker, | ||
final @NotNull Logger logger, | ||
final @NotNull Level level, | ||
final @Nullable String format, | ||
final @Nullable Object @Nullable [] params, | ||
final @Nullable Throwable t) { | ||
|
||
FilterReply filterReply = FilterReply.NEUTRAL; | ||
|
||
if (format == null || level == Level.OFF) { | ||
// format is the log message | ||
return filterReply; | ||
} | ||
|
||
for (final LogLevelModifier logLevelModifier : logLevelModifiers) { | ||
filterReply = logLevelModifier.decide(marker, logger, level, format, params, t); | ||
if (filterReply != FilterReply.NEUTRAL) { | ||
return filterReply; | ||
} | ||
} | ||
return filterReply; | ||
} | ||
|
||
public void registerLogLevelModifier(final @NotNull LogLevelModifier logLevelModifier) { | ||
logLevelModifiers.add(logLevelModifier); | ||
} | ||
} |
117 changes: 0 additions & 117 deletions
117
src/main/java/com/hivemq/logging/NettyLogLevelModifier.java
This file was deleted.
Oops, something went wrong.
79 changes: 0 additions & 79 deletions
79
src/main/java/com/hivemq/logging/XodusEnvironmentImplLogLevelModificator.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.