forked from I2P_Developers/i2p.i2p
Move upnp logging from wrapper log to router log
This commit is contained in:
@@ -51,6 +51,8 @@ public class UPnPManager {
|
||||
// UPnP wants to bind to IPv6 link local interfaces by default, but what UPnP router
|
||||
// is going to want to talk IPv6 anyway? Just make it easy and force IPv4 only
|
||||
org.cybergarage.upnp.UPnP.setEnable(org.cybergarage.upnp.UPnP.USE_ONLY_IPV4_ADDR);
|
||||
// set up logging in the UPnP package
|
||||
Debug.initialize(context);
|
||||
_upnp = new UPnP(context);
|
||||
_upnp.setHTTPPort(_context.getProperty(PROP_HTTP_PORT, DEFAULT_HTTP_PORT));
|
||||
_upnp.setSSDPPort(_context.getProperty(PROP_SSDP_PORT, DEFAULT_SSDP_PORT));
|
||||
@@ -59,10 +61,6 @@ public class UPnPManager {
|
||||
}
|
||||
|
||||
public synchronized void start() {
|
||||
if (_log.shouldLog(Log.DEBUG)) {
|
||||
_log.debug("UPnP Start");
|
||||
Debug.on(); // UPnP stuff -> wrapper log
|
||||
}
|
||||
if (!_isRunning)
|
||||
_isRunning = _upnp.runPlugin();
|
||||
if (!_isRunning)
|
||||
|
@@ -506,6 +506,6 @@ public class HTTPRequest extends HTTPPacket
|
||||
|
||||
public void print()
|
||||
{
|
||||
System.out.println(toString());
|
||||
Debug.message(toString());
|
||||
}
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
package org.cybergarage.http;
|
||||
|
||||
import java.io.*;
|
||||
import org.cybergarage.util.Debug;
|
||||
|
||||
public class HTTPResponse extends HTTPPacket
|
||||
{
|
||||
@@ -110,6 +111,6 @@ public class HTTPResponse extends HTTPPacket
|
||||
|
||||
public void print()
|
||||
{
|
||||
System.out.println(toString());
|
||||
Debug.message(toString());
|
||||
}
|
||||
}
|
||||
|
@@ -172,12 +172,12 @@ public class SOAPRequest extends HTTPRequest
|
||||
|
||||
public void print()
|
||||
{
|
||||
System.out.println(toString());
|
||||
Debug.message(toString());
|
||||
if (hasContent() == true)
|
||||
return;
|
||||
Node rootElem = getRootNode();
|
||||
if (rootElem == null)
|
||||
return;
|
||||
System.out.println(rootElem.toString());
|
||||
Debug.message(rootElem.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@
|
||||
package org.cybergarage.soap;
|
||||
|
||||
import org.cybergarage.http.*;
|
||||
import org.cybergarage.util.Debug;
|
||||
import org.cybergarage.xml.*;
|
||||
|
||||
public class SOAPResponse extends HTTPResponse
|
||||
@@ -180,12 +181,12 @@ public class SOAPResponse extends HTTPResponse
|
||||
|
||||
public void print()
|
||||
{
|
||||
System.out.println(toString());
|
||||
Debug.message(toString());
|
||||
if (hasContent() == true)
|
||||
return;
|
||||
Node rootElem = getRootNode();
|
||||
if (rootElem == null)
|
||||
return;
|
||||
System.out.println(rootElem.toString());
|
||||
Debug.message(rootElem.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -333,7 +333,7 @@ public class Action
|
||||
|
||||
public void print()
|
||||
{
|
||||
System.out.println("Action : " + getName());
|
||||
Debug.message("Action : " + getName());
|
||||
ArgumentList argList = getArgumentList();
|
||||
int nArgs = argList.size();
|
||||
for (int n=0; n<nArgs; n++) {
|
||||
@@ -341,7 +341,7 @@ public class Action
|
||||
String name = arg.getName();
|
||||
String value = arg.getValue();
|
||||
String dir = arg.getDirection();
|
||||
System.out.println(" [" + n + "] = " + dir + ", " + name + ", " + value);
|
||||
Debug.message(" [" + n + "] = " + dir + ", " + name + ", " + value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,8 +15,20 @@
|
||||
|
||||
package org.cybergarage.util;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
public final class Debug
|
||||
{
|
||||
private static Log _log;
|
||||
|
||||
/** I2P this is all static so have the UPnPManager call this */
|
||||
public static void initialize(I2PAppContext ctx) {
|
||||
_log = ctx.logManager().getLog(Debug.class);
|
||||
// org.cybergarage.util.Debug=DEBUG at startup
|
||||
enabled = _log.shouldLog(Log.DEBUG);
|
||||
}
|
||||
|
||||
public static boolean enabled = false;
|
||||
|
||||
public static final void on() {
|
||||
@@ -29,23 +41,25 @@ public final class Debug
|
||||
return enabled;
|
||||
}
|
||||
public static final void message(String s) {
|
||||
if (enabled == true)
|
||||
System.out.println("UPnP message : " + s);
|
||||
if (_log != null)
|
||||
_log.debug(s);
|
||||
}
|
||||
public static final void message(String m1, String m2) {
|
||||
if (enabled == true)
|
||||
System.out.println("UPnP message : ");
|
||||
System.out.println(m1);
|
||||
System.out.println(m2);
|
||||
if (_log != null) {
|
||||
_log.debug(m1);
|
||||
_log.debug(m2);
|
||||
}
|
||||
}
|
||||
public static final void warning(String s) {
|
||||
System.out.println("UPnP warning : " + s);
|
||||
if (_log != null)
|
||||
_log.error(s);
|
||||
}
|
||||
public static final void warning(String m, Exception e) {
|
||||
System.out.println("UPnP warning : " + m + " (" + e.getMessage() + ")");
|
||||
if (_log != null)
|
||||
_log.error(m, e);
|
||||
}
|
||||
public static final void warning(Exception e) {
|
||||
warning(e.getMessage());
|
||||
e.printStackTrace();
|
||||
if (_log != null)
|
||||
_log.error("", e);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user