Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
1.1.1
Browse files Browse the repository at this point in the history
* actually fix logging
  • Loading branch information
phit committed Apr 18, 2017
1 parent 434bd49 commit 6c7d638
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 59 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = 'de.sldk.mc.prometheusexporter'
version = '1.1.0'
version = '1.1.1'
description = "Sponge Minecraft Prometheus Exporter"
ext.url = 'https://github.com/Stonebound/minecraft-prometheus-exporter'

Expand Down
63 changes: 15 additions & 48 deletions src/main/java/de/sldk/mc/prometheusexporter/JettyNullLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,19 @@
import org.eclipse.jetty.util.log.Logger;

public class JettyNullLogger implements Logger {
public String getName() {
return "Jetty";
}

public void warn(String s, Object... objects) {
}

public void warn(Throwable throwable) {
}

public void warn(String s, Throwable throwable) {
}

public void info(String s, Object... objects) {
}

public void info(Throwable throwable) {
}

public void info(String s, Throwable throwable) {
}

public boolean isDebugEnabled() {
return false;
}

public void setDebugEnabled(boolean b) {
}

public void debug(String s, Object... objects) {
}

public void debug(String msg, long value) {

}

public void debug(Throwable throwable) {
}

public void debug(String s, Throwable throwable) {
}

public Logger getLogger(String s) {
return this;
}

public void ignore(Throwable throwable) {
}
@Override public String getName() { return "Jetty"; }
@Override public void warn(String msg, Object... args) { }
@Override public void warn(Throwable thrown) { }
@Override public void warn(String msg, Throwable thrown) { }
@Override public void info(String msg, Object... args) { }
@Override public void info(Throwable thrown) { }
@Override public void info(String msg, Throwable thrown) { }
@Override public boolean isDebugEnabled() { return false; }
@Override public void setDebugEnabled(boolean enabled) { }
@Override public void debug(String msg, Object... args) { }
@Override public void debug(String msg, long value) { }
@Override public void debug(Throwable thrown) { }
@Override public void debug(String msg, Throwable thrown) { }
@Override public Logger getLogger(String name) { return this; }
@Override public void ignore(Throwable ignored) { }
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ public void handle(String target, Request baseRequest, HttpServletRequest reques

baseRequest.setHandled(true);
} catch (IOException e) {
exporter.getLogger().error("Failed to read server statistics");
e.printStackTrace();
exporter.getLogger().error("Failed to read server statistics", e);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,23 @@ public class PrometheusExporter {
@Inject
@DefaultConfig(sharedRoot = false)
private File config;

@Inject
@DefaultConfig(sharedRoot = false)
private ConfigurationLoader<CommentedConfigurationNode> cfgMgr;
private ConfigurationNode cfg;

private static PrometheusExporter instance;
public static PrometheusExporter getInstance() {
return PrometheusExporter.instance;
}

@Inject
private Logger logger;
public Logger getLogger() {
return this.logger;
}

private static PrometheusExporter instance;
public static PrometheusExporter getInstance() {
return PrometheusExporter.instance;
}

@Listener
public void onPreinit(GamePreInitializationEvent event) {
logger.info("Setting up config...");
Expand All @@ -69,17 +70,16 @@ public void onPreinit(GamePreInitializationEvent event) {

@Listener
public void onServerStarted(GameStartedServerEvent event) {
org.eclipse.jetty.util.log.Log.setLog(new JettyNullLogger());
try {
server = new Server(port);

server.setHandler(new MetricsController(this));
server.start();

getLogger().info("Started Prometheus metrics endpoint on port " + port);
logger.info("Started Prometheus metrics endpoint on port " + port);

} catch (Exception e) {
getLogger().error("Could not start embedded Jetty server", e);
logger.error("Could not start embedded Jetty server", e);
}
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/jetty-logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.jetty.util.log.class=de.sldk.mc.prometheusexporter.JettyNullLogger

0 comments on commit 6c7d638

Please sign in to comment.