Un-static part 4: Logs

This commit is contained in:
zzz
2022-01-11 16:00:38 -05:00
parent 5e3878f9ad
commit eca5a15605
10 changed files with 17 additions and 20 deletions

View File

@ -72,8 +72,7 @@ public class SettingsFrame extends TabLogoPanel {
private static final Log _log = LogFactory.getLog(SettingsFrame.class); private final Log _log = LogFactory.getLog(SettingsFrame.class);
private static Boolean instanceShown = false;
// ConnectPanel // ConnectPanel
private JTextField txtRouterIP; private JTextField txtRouterIP;

View File

@ -16,7 +16,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class GetEcho { public class GetEcho {
private final static Log _log = LogFactory.getLog(GetEcho.class);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static String execute(String str) public static String execute(String str)
@ -34,8 +33,10 @@ public class GetEcho {
Map inParams = (HashMap) resp.getResult(); Map inParams = (HashMap) resp.getResult();
return (String) inParams.get("Result"); return (String) inParams.get("Result");
} catch (UnrecoverableFailedRequestException e) { } catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(GetEcho.class);
_log.error("GetEcho failed.", e); _log.error("GetEcho failed.", e);
} catch (InvalidParametersException e) { } catch (InvalidParametersException e) {
Log _log = LogFactory.getLog(GetEcho.class);
_log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString()); _log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString());
} }
return null; return null;

View File

@ -20,8 +20,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class GetI2PControl { public class GetI2PControl {
private final static Log _log = LogFactory.getLog(GetI2PControl.class);
public static EnumMap<I2P_CONTROL, Object> execute(I2P_CONTROL ... settings) public static EnumMap<I2P_CONTROL, Object> execute(I2P_CONTROL ... settings)
throws InvalidPasswordException, JSONRPC2SessionException{ throws InvalidPasswordException, JSONRPC2SessionException{
@ -58,8 +56,10 @@ public class GetI2PControl {
return new EnumMap<I2P_CONTROL, Object>(I2P_CONTROL.class); return new EnumMap<I2P_CONTROL, Object>(I2P_CONTROL.class);
} }
} catch (UnrecoverableFailedRequestException e) { } catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(GetI2PControl.class);
_log.error("getI2PControl failed.", e); _log.error("getI2PControl failed.", e);
} catch (InvalidParametersException e) { } catch (InvalidParametersException e) {
Log _log = LogFactory.getLog(GetI2PControl.class);
_log.error("getI2PControl was rejected by remote host as invalid.", e); _log.error("getI2PControl was rejected by remote host as invalid.", e);
} }
return null; return null;

View File

@ -22,7 +22,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class GetNetworkSetting { public class GetNetworkSetting {
private final static Log _log = LogFactory.getLog(GetNetworkSetting.class);
public static EnumMap<NETWORK_SETTING, Object> execute(NETWORK_SETTING ... options) public static EnumMap<NETWORK_SETTING, Object> execute(NETWORK_SETTING ... options)
throws InvalidPasswordException, JSONRPC2SessionException{ throws InvalidPasswordException, JSONRPC2SessionException{
@ -61,8 +60,10 @@ public class GetNetworkSetting {
return new EnumMap<NETWORK_SETTING, Object>(NETWORK_SETTING.class); return new EnumMap<NETWORK_SETTING, Object>(NETWORK_SETTING.class);
} }
} catch (UnrecoverableFailedRequestException e) { } catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(GetNetworkSetting.class);
_log.error("getNetworkInfo failed.", e); _log.error("getNetworkInfo failed.", e);
} catch (InvalidParametersException e) { } catch (InvalidParametersException e) {
Log _log = LogFactory.getLog(GetNetworkSetting.class);
_log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString()); _log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString());
} }
return null; return null;

View File

@ -17,7 +17,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class GetRateStat{ public class GetRateStat{
private final static Log _log = LogFactory.getLog(GetRateStat.class);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static Double execute(String stat, long period) public static Double execute(String stat, long period)
@ -42,6 +41,7 @@ public class GetRateStat{
Double dbl = (Double) inParams.get("Result"); Double dbl = (Double) inParams.get("Result");
return dbl; return dbl;
} catch (ClassCastException e){ } catch (ClassCastException e){
Log _log = LogFactory.getLog(GetRateStat.class);
_log.debug("Error: Tried to cast a BigDecimal as Double"); _log.debug("Error: Tried to cast a BigDecimal as Double");
} }
try { try {
@ -49,9 +49,11 @@ public class GetRateStat{
Double dbl = bigNum.doubleValue(); Double dbl = bigNum.doubleValue();
return dbl; return dbl;
} catch (ClassCastException e){ } catch (ClassCastException e){
Log _log = LogFactory.getLog(GetRateStat.class);
_log.debug("Error: Tried to cast a double as a BigDecimal"); _log.debug("Error: Tried to cast a double as a BigDecimal");
} }
}catch (UnrecoverableFailedRequestException e) { }catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(GetRateStat.class);
_log.error("getRateStat failed.", e); _log.error("getRateStat failed.", e);
} }
return new Double(0); return new Double(0);

View File

@ -23,7 +23,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class GetRouterInfo { public class GetRouterInfo {
private final static Log _log = LogFactory.getLog(GetRouterInfo.class);
private static HashMap<Integer, NETWORK_STATUS> enumMap; private static HashMap<Integer, NETWORK_STATUS> enumMap;
public static enum NETWORK_STATUS{ public static enum NETWORK_STATUS{
@ -89,8 +88,10 @@ public class GetRouterInfo {
return new EnumMap<ROUTER_INFO, Object>(ROUTER_INFO.class); return new EnumMap<ROUTER_INFO, Object>(ROUTER_INFO.class);
} }
} catch (UnrecoverableFailedRequestException e) { } catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(GetRouterInfo.class);
_log.error("getRouterInfo failed.", e); _log.error("getRouterInfo failed.", e);
} catch (InvalidParametersException e) { } catch (InvalidParametersException e) {
Log _log = LogFactory.getLog(GetRouterInfo.class);
_log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString()); _log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString());
} }
return null; return null;

View File

@ -20,8 +20,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class SetI2PControl { public class SetI2PControl {
private final static Log _log = LogFactory.getLog(SetI2PControl.class);
public static EnumMap<I2P_CONTROL, Object> execute(Map<I2P_CONTROL,String> settings) public static EnumMap<I2P_CONTROL, Object> execute(Map<I2P_CONTROL,String> settings)
throws InvalidPasswordException, JSONRPC2SessionException, InvalidParametersException{ throws InvalidPasswordException, JSONRPC2SessionException, InvalidParametersException{
@ -59,6 +57,7 @@ public class SetI2PControl {
return new EnumMap<I2P_CONTROL, Object>(I2P_CONTROL.class); return new EnumMap<I2P_CONTROL, Object>(I2P_CONTROL.class);
} }
} catch (UnrecoverableFailedRequestException e) { } catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(SetI2PControl.class);
_log.error("setI2PControl failed.", e); _log.error("setI2PControl failed.", e);
} }
return null; return null;

View File

@ -20,8 +20,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class SetNetworkSetting { public class SetNetworkSetting {
private final static Log _log = LogFactory.getLog(SetNetworkSetting.class);
public static EnumMap<NETWORK_SETTING, Object> execute(Map<NETWORK_SETTING,String> settings) public static EnumMap<NETWORK_SETTING, Object> execute(Map<NETWORK_SETTING,String> settings)
throws InvalidPasswordException, JSONRPC2SessionException, InvalidParametersException{ throws InvalidPasswordException, JSONRPC2SessionException, InvalidParametersException{
@ -59,6 +57,7 @@ public class SetNetworkSetting {
return new EnumMap<NETWORK_SETTING, Object>(NETWORK_SETTING.class); return new EnumMap<NETWORK_SETTING, Object>(NETWORK_SETTING.class);
} }
} catch (UnrecoverableFailedRequestException e) { } catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(SetNetworkSetting.class);
_log.error("setNetworkInfo failed.", e); _log.error("setNetworkInfo failed.", e);
} }
return null; return null;

View File

@ -22,8 +22,6 @@ import com.thetransactioncompany.jsonrpc2.JSONRPC2Response;
import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException; import com.thetransactioncompany.jsonrpc2.client.JSONRPC2SessionException;
public class SetRouterManager { public class SetRouterManager {
private final static Log _log = LogFactory.getLog(SetRouterManager.class);
public static EnumMap<ROUTER_MANAGER, Object> execute(Map<ROUTER_MANAGER,String> commands) public static EnumMap<ROUTER_MANAGER, Object> execute(Map<ROUTER_MANAGER,String> commands)
throws InvalidPasswordException, JSONRPC2SessionException{ throws InvalidPasswordException, JSONRPC2SessionException{
@ -63,8 +61,10 @@ public class SetRouterManager {
return new EnumMap<ROUTER_MANAGER, Object>(ROUTER_MANAGER.class); return new EnumMap<ROUTER_MANAGER, Object>(ROUTER_MANAGER.class);
} }
} catch (UnrecoverableFailedRequestException e) { } catch (UnrecoverableFailedRequestException e) {
Log _log = LogFactory.getLog(SetRouterManager.class);
_log.error("setRouterManager failed.", e); _log.error("setRouterManager failed.", e);
} catch (InvalidParametersException e) { } catch (InvalidParametersException e) {
Log _log = LogFactory.getLog(SetRouterManager.class);
_log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString()); _log.error("Remote host rejected provided parameters: " + req.toJSON().toJSONString());
} }
return null; return null;

View File

@ -23,18 +23,13 @@ import org.apache.commons.logging.LogFactory;
public class CertificateHelper { public class CertificateHelper {
private static Log _log;
static {
_log = LogFactory.getLog(CertificateHelper.class);
}
public static X509Certificate certFromBase64(String base64){ public static X509Certificate certFromBase64(String base64){
try { try {
CertificateFactory cf = CertificateFactory.getInstance(CertificateManager.DEFAULT_CERT_SPI); CertificateFactory cf = CertificateFactory.getInstance(CertificateManager.DEFAULT_CERT_SPI);
byte[] bytes = Base64.decode(base64); byte[] bytes = Base64.decode(base64);
return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(bytes)); return (X509Certificate) cf.generateCertificate(new ByteArrayInputStream(bytes));
} catch (CertificateException e) { } catch (CertificateException e) {
Log _log = LogFactory.getLog(CertificateHelper.class);
_log.fatal("Unable to load service interface provider, " + _log.fatal("Unable to load service interface provider, " +
CertificateManager.DEFAULT_CERT_SPI + CertificateManager.DEFAULT_CERT_SPI +
" used for reading base64 encoded certificates", e); " used for reading base64 encoded certificates", e);