Skip to content

Commit

Permalink
Fix for logger gets
Browse files Browse the repository at this point in the history
  • Loading branch information
mondain committed Jun 23, 2016
1 parent c4e2c38 commit a840063
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 42 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.red5</groupId>
<artifactId>red5-parent</artifactId>
<version>1.0.8-M2</version>
<version>1.0.8-M3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>red5-server-common</artifactId>
Expand Down
52 changes: 11 additions & 41 deletions src/main/java/org/red5/logging/Red5LoggerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public class Red5LoggerFactory {

static {
DEBUG = Boolean.valueOf(System.getProperty("logback.debug", "false"));
try {
Logger logger = LoggerFactory.getILoggerFactory().getLogger(Logger.ROOT_LOGGER_NAME);
logger.debug("Red5LoggerFactory instanced by Thread: {}", Thread.currentThread().getName());
} catch (Throwable t) {
t.printStackTrace();
}
}

public static Logger getLogger(Class<?> clazz) {
Expand Down Expand Up @@ -127,49 +133,16 @@ public static Logger getLogger(Class<?> clazz) {
}
logger = Red5LoggerFactory.getLogger(clazz, contextName);
*/
} else {
}
if (logger == null) {
logger = LoggerFactory.getLogger(clazz);
}
return logger;
}

@SuppressWarnings({ "rawtypes" })
public static Logger getLogger(Class clazz, String contextName) {
if (DEBUG) {
System.out.printf("getLogger for: %s in context: %s thread: %s%n", clazz.getName(), contextName, Thread.currentThread().getName());
}
Logger logger = null;
if (useLogback) {
// disallow null context names
if (contextName == null) {
contextName = CoreConstants.DEFAULT_CONTEXT_NAME;
}
try {
ContextSelector selector = Red5LoggerFactory.getContextSelector();
// get the context for the given context name or default if null
LoggerContext context = selector.getLoggerContext(contextName);
// and if we get here, create context
if (context == null) {
System.err.printf("No context named %s was found!%n", contextName);
}
// get the logger from the context or default context
if (context != null) {
logger = context.getLogger(clazz);
//System.out.printf("Application name: %s in context: %s%n", context.getProperty(KEY_APP_NAME), contextName);
}
} catch (Exception e) {
// no logback, use whatever logger is in-place
System.err.printf("Exception %s%n", e.getMessage());
e.printStackTrace();
}
if (logger == null) {
// no logback, use whatever logger is in-place
logger = LoggerFactory.getILoggerFactory().getLogger(Logger.ROOT_LOGGER_NAME);
}
} else {
logger = LoggerFactory.getLogger(clazz);
}
return logger;
return getLogger(clazz.getName(), contextName);
}

public static Logger getLogger(String name, String contextName) {
Expand Down Expand Up @@ -200,11 +173,8 @@ public static Logger getLogger(String name, String contextName) {
System.err.printf("Exception %s%n", e.getMessage());
e.printStackTrace();
}
if (logger == null) {
// no logback, use whatever logger is in-place
logger = LoggerFactory.getILoggerFactory().getLogger(name);
}
} else {
}
if (logger == null) {
logger = LoggerFactory.getLogger(name);
}
return logger;
Expand Down

0 comments on commit a840063

Please sign in to comment.