From d6fb4288688294d2f76325f14410db3091fea0fa Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 11 Jul 2016 12:25:03 +0300 Subject: logging --- juick-www/src/main/java/ru/sape/SapeConnection.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'juick-www/src/main/java/ru') diff --git a/juick-www/src/main/java/ru/sape/SapeConnection.java b/juick-www/src/main/java/ru/sape/SapeConnection.java index 8c794b08..dcaf629f 100644 --- a/juick-www/src/main/java/ru/sape/SapeConnection.java +++ b/juick-www/src/main/java/ru/sape/SapeConnection.java @@ -7,13 +7,12 @@ import java.io.Reader; import java.io.StringWriter; import java.net.HttpURLConnection; import java.net.URL; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; +import java.util.logging.Level; +import java.util.logging.Logger; public class SapeConnection { - + private static final Logger logger = Logger.getLogger(SapeConnection.class.getName()); private final String version = "1.0.3"; private final List serverList = Arrays.asList("dispenser-01.sape.ru", "dispenser-02.sape.ru"); private final String dispenserPath; @@ -80,7 +79,7 @@ public class SapeConnection { } if (data.startsWith("FATAL ERROR:")) { - System.err.println("Sape responded with error: " + data); + logger.log(Level.SEVERE, "Sape responded with error: " + data); continue; } @@ -88,7 +87,7 @@ public class SapeConnection { try { cached = (Map) new SerializedPhpParser(data).parse(); } catch (Exception e) { - System.err.println("Can't parse Sape data: " + e); + logger.log(Level.SEVERE, "Can't parse Sape data", e); continue; } @@ -97,9 +96,9 @@ public class SapeConnection { return cached; } - System.err.println("Unable to fetch Sape data"); + logger.log(Level.SEVERE, "Unable to fetch Sape data"); - return new HashMap(); + return Collections.emptyMap(); } return cached; -- cgit v1.2.3