Skip to content

Commit

Permalink
Merge pull request #145 from tobexyz/feat/issue122
Browse files Browse the repository at this point in the history
issue #122 changed log level of classes implementing the upnp stack
  • Loading branch information
tobexyz authored Dec 28, 2024
2 parents dc7f957 + c6c40ad commit e4ff55e
Show file tree
Hide file tree
Showing 91 changed files with 492 additions and 492 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public NetworkAddressFactory createNetworkAddressFactory() {
}

public void shutdown() {
Log.d(getClass().getName(), "Shutting down default executor service");
Log.v(getClass().getName(), "Shutting down default executor service");
getDefaultExecutorService().shutdownNow();
}

Expand Down Expand Up @@ -305,7 +305,7 @@ public ClingExecutor() {
@Override
public void rejectedExecution(Runnable runnable, ThreadPoolExecutor threadPoolExecutor) {
// Log and discard
Log.i(getClass().getName(), "Thread pool rejected execution of " + runnable.getClass());
Log.v(getClass().getName(), "Thread pool rejected execution of " + runnable.getClass());
super.rejectedExecution(runnable, threadPoolExecutor);
}
}
Expand Down
12 changes: 6 additions & 6 deletions yaacc/src/main/java/org/fourthline/cling/UpnpServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public UpnpServiceImpl(RegistryListener... registryListeners) {
public UpnpServiceImpl(UpnpServiceConfiguration configuration, RegistryListener... registryListeners) {
this.configuration = configuration;

Log.i(getClass().getName(), ">>> Starting UPnP service...");
Log.v(getClass().getName(), ">>> Starting UPnP service...");

Log.i(getClass().getName(), "Using configuration: " + getConfiguration().getClass().getName());
Log.v(getClass().getName(), "Using configuration: " + getConfiguration().getClass().getName());

// Instantiation order is important: Router needs to start its network services after registry is ready

Expand All @@ -90,7 +90,7 @@ public UpnpServiceImpl(UpnpServiceConfiguration configuration, RegistryListener.

this.controlPoint = createControlPoint(protocolFactory, registry);

Log.i(getClass().getName(), "<<< UPnP service started successfully");
Log.v(getClass().getName(), "<<< UPnP service started successfully");
}

protected ProtocolFactory createProtocolFactory() {
Expand Down Expand Up @@ -137,11 +137,11 @@ protected void shutdown(boolean separateThread) {
Runnable shutdown = new Runnable() {
@Override
public void run() {
Log.i(getClass().getName(), ">>> Shutting down UPnP service...");
Log.v(getClass().getName(), ">>> Shutting down UPnP service...");
shutdownRegistry();
shutdownRouter();
shutdownConfiguration();
Log.i(getClass().getName(), "<<< UPnP service shutdown completed");
Log.v(getClass().getName(), "<<< UPnP service shutdown completed");
}
};
if (separateThread) {
Expand All @@ -162,7 +162,7 @@ protected void shutdownRouter() {
} catch (RouterException ex) {
Throwable cause = Exceptions.unwrap(ex);
if (cause instanceof InterruptedException) {
Log.i(getClass().getName(), "Router shutdown was interrupted: " + ex, cause);
Log.v(getClass().getName(), "Router shutdown was interrupted: " + ex, cause);
} else {
Log.e(getClass().getName(), "Router error on shutdown: " + ex, cause);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Action appendAction(Map<Action, ActionExecutor> actions) throws LocalServ
name = AnnotationLocalServiceBinder.toUpnpActionName(getMethod().getName());
}

Log.d(getClass().getName(), "Creating action and executor: " + name);
Log.v(getClass().getName(), "Creating action and executor: " + name);

List<ActionArgument> inputArguments = createInputArguments();
Map<ActionArgument<LocalService>, StateVariableAccessor> outputArguments = createOutputArguments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class AnnotationLocalServiceBinder implements LocalServiceBinder {


public LocalService read(Class<?> clazz) throws LocalServiceBindingException {
Log.d(getClass().getName(), "Reading and binding annotations of service implementation class: " + clazz);
Log.v(getClass().getName(), "Reading and binding annotations of service implementation class: " + clazz);

// Read the service ID and service type from the annotation
if (clazz.isAnnotationPresent(UpnpService.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public Set<Class> getStringConvertibleTypes() {

protected StateVariable createStateVariable() throws LocalServiceBindingException {

Log.d(getClass().getName(), "Creating state variable '" + getName() + "' with accessor: " + getAccessor());
Log.v(getClass().getName(), "Creating state variable '" + getName() + "' with accessor: " + getAccessor());

// Datatype
Datatype datatype = createDatatype();
Expand All @@ -88,7 +88,7 @@ protected StateVariable createStateVariable() throws LocalServiceBindingExceptio
} else if (getAccessor() != null && getAccessor().getReturnType().isEnum()) {
allowedValues = getAllowedValues(getAccessor().getReturnType());
} else {
Log.d(getClass().getName(), "Not restricting allowed values (of string typed state var): " + getName());
Log.v(getClass().getName(), "Not restricting allowed values (of string typed state var): " + getName());
}

if (allowedValues != null && defaultValue != null) {
Expand Down Expand Up @@ -122,7 +122,7 @@ protected StateVariable createStateVariable() throws LocalServiceBindingExceptio
getAnnotation().allowedValueStep()
);
} else {
Log.d(getClass().getName(), "Not restricting allowed value range (of numeric typed state var): " + getName());
Log.v(getClass().getName(), "Not restricting allowed value range (of numeric typed state var): " + getName());
}

// Check if the default value is an allowed value
Expand Down Expand Up @@ -157,13 +157,13 @@ protected StateVariable createStateVariable() throws LocalServiceBindingExceptio
int eventMinimumDelta = 0;
if (sendEvents) {
if (getAnnotation().eventMaximumRateMilliseconds() > 0) {
Log.d(getClass().getName(), "Moderating state variable events using maximum rate (milliseconds): " + getAnnotation().eventMaximumRateMilliseconds());
Log.v(getClass().getName(), "Moderating state variable events using maximum rate (milliseconds): " + getAnnotation().eventMaximumRateMilliseconds());
eventMaximumRateMillis = getAnnotation().eventMaximumRateMilliseconds();
}

if (getAnnotation().eventMinimumDelta() > 0 && Datatype.Builtin.isNumeric(datatype.getBuiltin())) {
// TODO: Doesn't consider floating point types!
Log.d(getClass().getName(), "Moderating state variable events using minimum delta: " + getAnnotation().eventMinimumDelta());
Log.v(getClass().getName(), "Moderating state variable events using minimum delta: " + getAnnotation().eventMinimumDelta());
eventMinimumDelta = getAnnotation().eventMinimumDelta();
}
}
Expand All @@ -183,16 +183,16 @@ protected Datatype createDatatype() throws LocalServiceBindingException {

if (declaredDatatype.length() == 0 && getAccessor() != null) {
Class returnType = getAccessor().getReturnType();
Log.d(getClass().getName(), "Using accessor return type as state variable type: " + returnType);
Log.v(getClass().getName(), "Using accessor return type as state variable type: " + returnType);

if (ModelUtil.isStringConvertibleType(getStringConvertibleTypes(), returnType)) {
// Enums and toString() convertible types are always state variables with type STRING
Log.d(getClass().getName(), "Return type is string-convertible, using string datatype");
Log.v(getClass().getName(), "Return type is string-convertible, using string datatype");
return Datatype.Default.STRING.getBuiltinType().getDatatype();
} else {
Datatype.Default defaultDatatype = Datatype.Default.getByJavaType(returnType);
if (defaultDatatype != null) {
Log.d(getClass().getName(), "Return type has default UPnP datatype: " + defaultDatatype);
Log.v(getClass().getName(), "Return type has default UPnP datatype: " + defaultDatatype);
return defaultDatatype.getBuiltinType().getDatatype();
}
}
Expand All @@ -201,7 +201,7 @@ protected Datatype createDatatype() throws LocalServiceBindingException {
// We can also guess that if the allowed values are set then it's a string
if ((declaredDatatype == null || declaredDatatype.length() == 0) &&
(getAnnotation().allowedValues().length > 0 || getAnnotation().allowedValuesEnum() != void.class)) {
Log.d(getClass().getName(), "State variable has restricted allowed values, hence using 'string' datatype");
Log.v(getClass().getName(), "State variable has restricted allowed values, hence using 'string' datatype");
declaredDatatype = "string";
}

Expand All @@ -210,12 +210,12 @@ protected Datatype createDatatype() throws LocalServiceBindingException {
throw new LocalServiceBindingException("Could not detect datatype of state variable: " + getName());
}

Log.d(getClass().getName(), "Trying to find built-in UPnP datatype for detected name: " + declaredDatatype);
Log.v(getClass().getName(), "Trying to find built-in UPnP datatype for detected name: " + declaredDatatype);

// Now try to find the actual UPnP datatype by mapping the Default to Builtin
Datatype.Builtin builtin = Datatype.Builtin.getByDescriptorName(declaredDatatype);
if (builtin != null) {
Log.d(getClass().getName(), "Found built-in UPnP datatype: " + builtin);
Log.v(getClass().getName(), "Found built-in UPnP datatype: " + builtin);
return builtin.getDatatype();
} else {
// TODO
Expand All @@ -230,7 +230,7 @@ protected String createDefaultValue(Datatype datatype) throws LocalServiceBindin
// The declared default value needs to match the datatype
try {
datatype.valueOf(getAnnotation().defaultValue());
Log.d(getClass().getName(), "Found state variable default value: " + getAnnotation().defaultValue());
Log.v(getClass().getName(), "Found state variable default value: " + getAnnotation().defaultValue());
return getAnnotation().defaultValue();
} catch (Exception ex) {
throw new LocalServiceBindingException(
Expand All @@ -248,7 +248,7 @@ protected String[] getAllowedValues(Class enumType) throws LocalServiceBindingEx
throw new LocalServiceBindingException("Allowed values type is not an Enum: " + enumType);
}

Log.d(getClass().getName(), "Restricting allowed values of state variable to Enum: " + getName());
Log.v(getClass().getName(), "Restricting allowed values of state variable to Enum: " + getName());
String[] allowedValueStrings = new String[enumType.getEnumConstants().length];
for (int i = 0; i < enumType.getEnumConstants().length; i++) {
Object o = enumType.getEnumConstants()[i];
Expand All @@ -257,7 +257,7 @@ protected String[] getAllowedValues(Class enumType) throws LocalServiceBindingEx
"Allowed value string (that is, Enum constant name) is longer than 32 characters: " + o.toString()
);
}
Log.d(getClass().getName(), "Adding allowed value (converted to string): " + o.toString());
Log.v(getClass().getName(), "Adding allowed value (converted to string): " + o.toString());
allowedValueStrings[i] = o.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,18 +176,18 @@ protected String fixMissingNamespaces(String descriptorXml, DescriptorBindingExc
pattern = Pattern.compile("<root([^>]*)");
matcher = pattern.matcher(descriptorXml);
if (!matcher.find() || matcher.groupCount() != 1) {
Log.d(getClass().getName(), "Could not find <root> element attributes");
Log.v(getClass().getName(), "Could not find <root> element attributes");
return null;
}

String rootAttributes = matcher.group(1);
Log.d(getClass().getName(), "Preserving existing <root> element attributes/namespace declarations: " + matcher.group(0));
Log.v(getClass().getName(), "Preserving existing <root> element attributes/namespace declarations: " + matcher.group(0));

// Extract <root> body
pattern = Pattern.compile("<root[^>]*>(.*)</root>", Pattern.DOTALL);
matcher = pattern.matcher(descriptorXml);
if (!matcher.find() || matcher.groupCount() != 1) {
Log.d(getClass().getName(), "Could not extract body of <root> element");
Log.v(getClass().getName(), "Could not extract body of <root> element");
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public <D extends Device> D describe(D undescribedDevice, String descriptorXml)
}

try {
Log.d(getClass().getName(), "Populating device from XML descriptor: " + undescribedDevice);
Log.v(getClass().getName(), "Populating device from XML descriptor: " + undescribedDevice);
// We can not validate the XML document. There is no possible XML schema (maybe RELAX NG) that would properly
// constrain the UDA 1.0 device descriptor documents: Any unknown element or attribute must be ignored, order of elements
// is not guaranteed. Try to write a schema for that! No combination of <xsd:any namespace="##any"> and <xsd:choice>
Expand Down Expand Up @@ -107,7 +107,7 @@ public <D extends Device> D describe(D undescribedDevice, String descriptorXml)

public <D extends Device> D describe(D undescribedDevice, Document dom) throws DescriptorBindingException, ValidationException {
try {
Log.d(getClass().getName(), "Populating device from DOM: " + undescribedDevice);
Log.v(getClass().getName(), "Populating device from DOM: " + undescribedDevice);

// Read the XML into a mutable descriptor graph
MutableDevice descriptor = new MutableDevice();
Expand Down Expand Up @@ -250,7 +250,7 @@ public void hydrateDevice(MutableDevice descriptor, Node deviceNode) throws Desc
try {
descriptor.dlnaDocs.add(DLNADoc.valueOf(txt));
} catch (InvalidValueException ex) {
Log.i(getClass().getName(), "Invalid X_DLNADOC value, ignoring value: " + txt);
Log.v(getClass().getName(), "Invalid X_DLNADOC value, ignoring value: " + txt);
}
} else if (ELEMENT.X_DLNACAP.equals(deviceNodeChild) &&
Descriptor.Device.DLNA_PREFIX.equals(deviceNodeChild.getPrefix())) {
Expand Down Expand Up @@ -390,7 +390,7 @@ public String generate(Device deviceModel, RemoteClientInfo info, Namespace name
public Document buildDOM(Device deviceModel, RemoteClientInfo info, Namespace namespace) throws DescriptorBindingException {

try {
Log.d(getClass().getName(), "Generating DOM from device model: " + deviceModel);
Log.v(getClass().getName(), "Generating DOM from device model: " + deviceModel);

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
Expand Down Expand Up @@ -604,7 +604,7 @@ static protected URI parseURI(String uri) {
at java.net.URI.<init>(URI.java:87)
at java.net.URI.create(URI.java:968)
*/
Log.d(UDA10DeviceDescriptorBinderImpl.class.getName(), "Illegal URI, trying with ./ prefix: " + Exceptions.unwrap(ex));
Log.v(UDA10DeviceDescriptorBinderImpl.class.getName(), "Illegal URI, trying with ./ prefix: " + Exceptions.unwrap(ex));
// Ignore
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public <D extends Device> D describe(D undescribedDevice, String descriptorXml)
}

try {
Log.d(getClass().getName(), "Populating device from XML descriptor: " + undescribedDevice);
Log.v(getClass().getName(), "Populating device from XML descriptor: " + undescribedDevice);

// Read the XML into a mutable descriptor graph

Expand Down Expand Up @@ -234,7 +234,7 @@ public void endElement(ELEMENT element) throws SAXException {
try {
getInstance().dlnaDocs.add(DLNADoc.valueOf(txt));
} catch (InvalidValueException ex) {
Log.i(getClass().getName(), "Invalid X_DLNADOC value, ignoring value: " + txt);
Log.v(getClass().getName(), "Invalid X_DLNADOC value, ignoring value: " + txt);
}
break;
case X_DLNACAP:
Expand Down Expand Up @@ -379,7 +379,7 @@ public void endElement(ELEMENT element) throws SAXException {
break;
}
} catch (InvalidValueException ex) {
Log.d(getClass().getName(),
Log.v(getClass().getName(),
"UPnP specification violation, skipping invalid service declaration. " + ex.getMessage()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public <S extends Service> S describe(S undescribedService, String descriptorXml
}

try {
Log.d(getClass().getName(), "Populating service from XML descriptor: " + undescribedService);
Log.v(getClass().getName(), "Populating service from XML descriptor: " + undescribedService);

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
Expand All @@ -94,7 +94,7 @@ public <S extends Service> S describe(S undescribedService, String descriptorXml

public <S extends Service> S describe(S undescribedService, Document dom) throws DescriptorBindingException, ValidationException {
try {
Log.d(getClass().getName(), "Populating service from DOM: " + undescribedService);
Log.v(getClass().getName(), "Populating service from DOM: " + undescribedService);

// Read the XML into a mutable descriptor graph
MutableService descriptor = new MutableService();
Expand Down Expand Up @@ -350,7 +350,7 @@ public void hydrateStateVariable(MutableStateVariable stateVariable, Element sta

public String generate(Service service) throws DescriptorBindingException {
try {
Log.d(getClass().getName(), "Generating XML descriptor from service model: " + service);
Log.v(getClass().getName(), "Generating XML descriptor from service model: " + service);

return XMLUtil.documentToString(buildDOM(service));

Expand All @@ -362,7 +362,7 @@ public String generate(Service service) throws DescriptorBindingException {
public Document buildDOM(Service service) throws DescriptorBindingException {

try {
Log.d(getClass().getName(), "Generating XML descriptor from service model: " + service);
Log.v(getClass().getName(), "Generating XML descriptor from service model: " + service);

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public <S extends Service> S describe(S undescribedService, String descriptorXml
}

try {
Log.d(getClass().getName(), "Reading service from XML descriptor");
Log.v(getClass().getName(), "Reading service from XML descriptor");

SAXParser parser = new SAXParser();

Expand Down
Loading

0 comments on commit e4ff55e

Please sign in to comment.