|
| 1 | +/* |
| 2 | + * Copyright 2024 John Grosh <john.a.grosh@gmail.com>. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package com.jagrosh.jmusicbot.utils; |
| 17 | + |
| 18 | +import ch.qos.logback.classic.Level; |
| 19 | +import ch.qos.logback.classic.Logger; |
| 20 | +import ch.qos.logback.classic.turbo.TurboFilter; |
| 21 | +import ch.qos.logback.core.spi.FilterReply; |
| 22 | +import org.slf4j.Marker; |
| 23 | + |
| 24 | +/** |
| 25 | + * A TurboFilter, currently only used to suppress specific log messages from libraries. |
| 26 | + * |
| 27 | + * @author Michaili K. <git@michaili.dev> |
| 28 | + */ |
| 29 | +public class LogBackTurboFilter extends TurboFilter |
| 30 | +{ |
| 31 | + @Override |
| 32 | + public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) |
| 33 | + { |
| 34 | + // Suppresses the auth token warning from the YoutubeAudioSourceManager |
| 35 | + // https://github.com/jagrosh/MusicBot/pull/1490#issuecomment-1974070225 |
| 36 | + if (logger.getName().equals("com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAccessTokenTracker") |
| 37 | + && format.equals("YouTube auth tokens can't be retrieved because email and password is not set in YoutubeAudioSourceManager, age restricted videos will throw exceptions.") |
| 38 | + ) { |
| 39 | + return FilterReply.DENY; |
| 40 | + } |
| 41 | + |
| 42 | + return FilterReply.NEUTRAL; |
| 43 | + } |
| 44 | +} |
0 commit comments