Author: fmeschbe
Date: Thu Jun 12 07:29:45 2008
New Revision: 667104
URL: http://svn.apache.org/viewvc?rev=667104&view=rev
Log:
SLING-527 Fall back to use the bundle location or bundle ID if the
bundle for which a logger is requested has no symbolic name
Modified:
incubator/sling/trunk/commons/log/src/main/java/org/apache/sling/commons/log/LogSupport.java
Modified:
incubator/sling/trunk/commons/log/src/main/java/org/apache/sling/commons/log/LogSupport.java
URL:
http://svn.apache.org/viewvc/incubator/sling/trunk/commons/log/src/main/java/org/apache/sling/commons/log/LogSupport.java?rev=667104&r1=667103&r2=667104&view=diff
==============================================================================
---
incubator/sling/trunk/commons/log/src/main/java/org/apache/sling/commons/log/LogSupport.java
(original)
+++
incubator/sling/trunk/commons/log/src/main/java/org/apache/sling/commons/log/LogSupport.java
Thu Jun 12 07:29:45 2008
@@ -315,10 +315,29 @@
Long bundleId = new Long((bundle == null) ? 0 : bundle.getBundleId());
Logger log = this.loggers.get(bundleId);
if (log == null) {
- // TODO: use systembundle for bundle==null
- String name = (bundle == null)
- ? Constants.SYSTEM_BUNDLE_SYMBOLICNAME
- : bundle.getSymbolicName();
+
+ String name;
+ if (bundle == null) {
+
+ // if we have no bundle, use the system bundle's name
+ name = Constants.SYSTEM_BUNDLE_SYMBOLICNAME;
+
+ } else {
+
+ // otherwise use the bundle symbolic name
+ name = bundle.getSymbolicName();
+
+ // if the bundle has no symbolic name, use the location
+ if (name == null) {
+ name = bundle.getLocation();
+ }
+
+ // if the bundle also has no location, use the bundle Id
+ if (name == null) {
+ name = String.valueOf(bundle.getBundleId());
+ }
+ }
+
log = LoggerFactory.getLogger(name);
this.loggers.put(bundleId, log);
}