Merge pull request #21 from B00tLoad/18-get-rid-of-javalin-and-lastfm-logging
18 get rid of javalin and lastfm logging
This commit was merged in pull request #21.
This commit is contained in:
5
pom.xml
5
pom.xml
@@ -102,6 +102,11 @@
|
||||
<artifactId>javalin</artifactId>
|
||||
<version>5.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<version>2.0.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -4,17 +4,17 @@ package de.b00tload.tools.lastfmtospotifyplaylist;
|
||||
import com.neovisionaries.i18n.CountryCode;
|
||||
import de.b00tload.tools.lastfmtospotifyplaylist.arguments.ArgumentHandler;
|
||||
import de.b00tload.tools.lastfmtospotifyplaylist.arguments.Arguments;
|
||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.BrowserHelper;
|
||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.PeriodHelper;
|
||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.*;
|
||||
|
||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.SpotifyCredentials;
|
||||
import de.b00tload.tools.lastfmtospotifyplaylist.util.TokenHelper;
|
||||
import de.umass.lastfm.Caller;
|
||||
import de.umass.lastfm.Track;
|
||||
import de.umass.lastfm.User;
|
||||
import io.javalin.Javalin;
|
||||
import io.javalin.http.ContentType;
|
||||
import io.javalin.http.HttpStatus;
|
||||
import io.javalin.jetty.JettyUtil;
|
||||
import io.javalin.util.JavalinLogger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import se.michaelthelin.spotify.SpotifyApi;
|
||||
import se.michaelthelin.spotify.model_objects.specification.Playlist;
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.b00tload.tools.lastfmtospotifyplaylist.util.Logger.logLn;
|
||||
|
||||
@@ -73,6 +74,11 @@ public class LastFMToSpotify {
|
||||
}
|
||||
}
|
||||
|
||||
if(Integer.parseInt(configuration.get("logging.level")) != 3){
|
||||
JavalinLogger.enabled = false;
|
||||
System.setErr(new Logger.LogStream(System.err));
|
||||
}
|
||||
|
||||
try {
|
||||
logLn("Authenticating with Spotify...", 1);
|
||||
SpotifyApi.Builder build = SpotifyApi.builder();
|
||||
@@ -130,6 +136,7 @@ public class LastFMToSpotify {
|
||||
logLn("Authenticating with LastFM...", 1);
|
||||
Caller.getInstance().setApiRootUrl("https://ws.audioscrobbler.com/2.0/");
|
||||
Caller.getInstance().setUserAgent(configuration.get("requests.useragent"));
|
||||
if(Integer.parseInt(configuration.get("logging.level")) != 3) Caller.getInstance().getLogger().setLevel(Level.OFF);
|
||||
logLn(User.getInfo(configuration.get("lastfm.user"), configuration.get("lastfm.apikey")).getName(), 1);
|
||||
logLn("Reading from LastFM...", 1);
|
||||
Collection<Track> tracks = User.getTopTracks(configuration.get("lastfm.user"), PeriodHelper.getPeriodByString(configuration.get("lastfm.period")), configuration.get("lastfm.apikey"));
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package de.b00tload.tools.lastfmtospotifyplaylist.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import static de.b00tload.tools.lastfmtospotifyplaylist.LastFMToSpotify.configuration;
|
||||
|
||||
public class Logger {
|
||||
@@ -15,4 +21,31 @@ public class Logger {
|
||||
}
|
||||
}
|
||||
|
||||
public static class LogStream extends PrintStream{
|
||||
|
||||
public LogStream(@NotNull OutputStream out) {
|
||||
super(out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) {
|
||||
if(Integer.parseInt(configuration.get("logging.level"))==3) super.write(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] buf) throws IOException {
|
||||
if(Integer.parseInt(configuration.get("logging.level"))==3) super.write(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(@NotNull byte[] buf, int off, int len) {
|
||||
if(Integer.parseInt(configuration.get("logging.level"))==3) super.write(buf, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeBytes(byte[] buf) {
|
||||
if(Integer.parseInt(configuration.get("logging.level"))==3) super.writeBytes(buf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user